├── .gitignore ├── Makefile ├── README.md ├── assets ├── assets.fla ├── assets.swc ├── font │ ├── PlaybackSans-Black.otf │ ├── PlaybackSans-Bold.otf │ ├── PlaybackSans-Light.otf │ ├── PlaybackSans-Regular.otf │ └── PlaybackSansEULA.txt ├── readme.txt └── src │ ├── MaskedMovieClip.as │ └── MovieClipRow.as ├── index.html ├── libs ├── OSMF.swc └── at │ └── matthew │ └── httpstreaming │ ├── HTTPStreamingH264NALU.as │ ├── HTTPStreamingM3U8Factory.as │ ├── HTTPStreamingM3U8IndexHandler.as │ ├── HTTPStreamingM3U8IndexItem.as │ ├── HTTPStreamingM3U8IndexRateItem.as │ ├── HTTPStreamingM3U8NetLoader.as │ ├── HTTPStreamingM3U8NetLoaderAdapter.as │ ├── HTTPStreamingMP2PESAudio.as │ ├── HTTPStreamingMP2PESBase.as │ ├── HTTPStreamingMP2PESVideo.as │ ├── HTTPStreamingMP2TSFileHandler.as │ ├── M3U8Element.as │ ├── M3U8IndexInfo.as │ ├── M3U8Loader.as │ ├── M3U8Metadata.as │ ├── M3U8StreamInfo.as │ └── M3U8Utils.as └── src ├── StrobeMediaPlayback.as └── org └── osmf ├── net ├── HTTPStreamingNetLoaderAdapter.as ├── MulticastNetLoaderAdapter.as ├── NetStreamBufferManagerBase.as ├── PlaybackOptimizationManager.as ├── PlaybackOptimizationMetrics.as ├── RTMPDynamicStreamingNetLoaderAdapter.as ├── RunningAverage.as └── StrobeNetStreamSwitchManager.as └── player ├── chrome ├── AssetsProvider.as ├── ChromeProvider.as ├── ControlBar.as ├── IControlBar.as ├── SmartphoneControlBar.as ├── TabletControlBar.as ├── VolumeControlBar.as ├── assets │ ├── Asset.as │ ├── AssetIDs.as │ ├── AssetLoader.as │ ├── AssetResource.as │ ├── AssetsManager.as │ ├── BitmapAsset.as │ ├── BitmapResource.as │ ├── DisplayObjectAsset.as │ ├── FontAsset.as │ ├── FontResource.as │ ├── SWFAsset.as │ ├── Scale9Bitmap.as │ ├── SymbolAsset.as │ └── SymbolResource.as ├── configuration │ ├── AssetsParser.as │ ├── Configuration.as │ ├── ConfigurationUtils.as │ ├── LayoutAttributesParser.as │ └── WidgetsParser.as ├── events │ ├── ScrubberEvent.as │ └── WidgetEvent.as ├── hint │ ├── Hint.as │ └── WidgetHint.as ├── metadata │ └── ChromeMetadata.as ├── utils │ ├── FormatUtils.as │ └── MediaElementUtils.as └── widgets │ ├── AlertDialog.as │ ├── AuthenticationDialog.as │ ├── AutoHideWidget.as │ ├── BackButton.as │ ├── BufferingOverlay.as │ ├── ButtonHighlight.as │ ├── ButtonWidget.as │ ├── CurrentTimeWidget.as │ ├── FadingLayoutTargetSprite.as │ ├── FullScreenEnterButton.as │ ├── FullScreenLeaveButton.as │ ├── LabelWidget.as │ ├── MuteButton.as │ ├── PauseButton.as │ ├── PlayButton.as │ ├── PlayButtonOverlay.as │ ├── PlayableButton.as │ ├── PlaylistNextButton.as │ ├── PlaylistPreviousButton.as │ ├── QualityIndicator.as │ ├── ScrubBar.as │ ├── Slider.as │ ├── TimeHintWidget.as │ ├── TimeLabelWidget.as │ ├── TimeViewWidget.as │ ├── TotalTimeWidget.as │ ├── VideoInfoOverlay.as │ ├── VolumeWidget.as │ ├── Widget.as │ └── WidgetIDs.as ├── configuration ├── ConfigurationFlashvarsDeserializer.as ├── ConfigurationLoader.as ├── ConfigurationProxy.as ├── ConfigurationXMLDeserializer.as ├── ControlBarMode.as ├── ControlBarType.as ├── InjectorModule.as ├── JavaScriptBridge.as ├── PlayerConfiguration.as ├── SkinParser.as ├── VideoRenderingMode.as └── XMLFileLoader.as ├── containers └── StrobeMediaContainer.as ├── debug ├── DebugStrobeMediaPlayer.as ├── LogHandler.as ├── LogMessage.as ├── StrobeLogger.as ├── StrobeLoggerFactory.as └── qos │ ├── BufferIndicators.as │ ├── DynamicStreamingIndicators.as │ ├── IndicatorsBase.as │ ├── QoSDashboard.as │ └── RenderingIndicators.as ├── elements ├── AlertDialogElement.as ├── AuthenticationDialogElement.as ├── ControlBarElement.as ├── ErrorElement.as ├── ErrorWidget.as ├── PlaylistElement.as ├── VolumeBarElement.as └── playlistClasses │ ├── InnerPlaylistElement.as │ ├── PlaylistAudioTrait.as │ ├── PlaylistLoadTrait.as │ ├── PlaylistLoader.as │ ├── PlaylistMetadata.as │ ├── PlaylistParser.as │ ├── PlaylistPlayTrait.as │ ├── PlaylistTimeTrait.as │ ├── PlaylistTraitEvent.as │ ├── ProxyElementEx.as │ └── ProxyMetadataEx.as ├── errors ├── ErrorTranslator.as ├── StrobePlayerError.as └── StrobePlayerErrorCodes.as ├── media ├── StrobeMediaFactory.as ├── StrobeMediaPlayer.as └── VideoElementRegistry.as ├── metadata ├── MediaMetadata.as ├── ResourceMetadata.as └── StrobeDynamicMetadata.as ├── plugins └── PluginLoader.as └── utils ├── StrobePlayerStrings.as ├── StrobeUtils.as └── VideoRenderingUtils.as /.gitignore: -------------------------------------------------------------------------------- 1 | SMPHLS.swf 2 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | mxmlc -output SMPHLS.swf \ 3 | -source-path libs \ 4 | -library-path assets \ 5 | -library-path libs \ 6 | -static-rsls \ 7 | -define CONFIG::LOGGING false \ 8 | -define CONFIG::FLASH_10_1 true \ 9 | src/StrobeMediaPlayback.as 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | HLS Flash player 2 | --------------- 3 | 4 | This is a complete HLS flash player. 5 | 6 | It contains two important folders: src and libs/at. 7 | 8 | src contains StrobeMediaPlayback flash player by Adobe in sources. These sources are modified a bit to be able to load m3u8 manifests 9 | 10 | libs/at contains code origined from https://code.google.com/p/apple-http-osmf/ by Matthew Kaufman 11 | and it was modified by Mihail Latyshov https://github.com/kutu 12 | 13 | 14 | 15 | Mihail has developed a superior version of HLS plugin from scratch: http://osmfhls.kutu.ru/ 16 | 17 | 18 | 19 | Source code is distributed under Mozilla Public License 1.1 as original code. 20 | 21 | 22 | How to build 23 | =========== 24 | 25 | 26 | export PATH=$PATH:/usr/local/flex_sdk_4/bin 27 | make 28 | 29 | You will see: 30 | 31 | hlsplayer max$ export PATH=$PATH:/usr/local/flex_sdk_4/bin 32 | hlsplayer max$ make 33 | mxmlc -output SMPHLS.swf \ 34 | -source-path libs \ 35 | -library-path assets \ 36 | -library-path libs \ 37 | -static-rsls \ 38 | -define CONFIG::LOGGING false \ 39 | -define CONFIG::FLASH_10_1 true \ 40 | src/StrobeMediaPlayback.as 41 | Loading configuration file /usr/local/flex_sdk_4/frameworks/flex-config.xml 42 | /Users/max/Sites/hlsplayer/SMPHLS.swf (282726 bytes) 43 | 44 | 45 | How to use 46 | ========== 47 | 48 | 49 | Take commercial version of http://erlyvideo.org/ (or any other HLS video server), launch it and add following code to your webpage: 50 | 51 |
Video should be here
52 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /assets/assets.fla: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erlyvideo/hlsplayer/d5b060883c89cd2e31ab243bb31b1c5fc158ffb0/assets/assets.fla -------------------------------------------------------------------------------- /assets/assets.swc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erlyvideo/hlsplayer/d5b060883c89cd2e31ab243bb31b1c5fc158ffb0/assets/assets.swc -------------------------------------------------------------------------------- /assets/font/PlaybackSans-Black.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erlyvideo/hlsplayer/d5b060883c89cd2e31ab243bb31b1c5fc158ffb0/assets/font/PlaybackSans-Black.otf -------------------------------------------------------------------------------- /assets/font/PlaybackSans-Bold.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erlyvideo/hlsplayer/d5b060883c89cd2e31ab243bb31b1c5fc158ffb0/assets/font/PlaybackSans-Bold.otf -------------------------------------------------------------------------------- /assets/font/PlaybackSans-Light.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erlyvideo/hlsplayer/d5b060883c89cd2e31ab243bb31b1c5fc158ffb0/assets/font/PlaybackSans-Light.otf -------------------------------------------------------------------------------- /assets/font/PlaybackSans-Regular.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erlyvideo/hlsplayer/d5b060883c89cd2e31ab243bb31b1c5fc158ffb0/assets/font/PlaybackSans-Regular.otf -------------------------------------------------------------------------------- /assets/font/PlaybackSansEULA.txt: -------------------------------------------------------------------------------- 1 | Playback Sans is released under the SIL Open Font License - please read it carefully and do not download the fonts unless you agree to the the terms of the license: 2 | 3 | Copyright © 2010, Adobe Systems, Inc. (http://www.adobe.com/), 4 | with Reserved Font Name Playback Sans 5 | 6 | This Font Software is licensed under the SIL Open Font License, Version 1.1. 7 | 8 | This license is copied below, and is also available with a FAQ at: 9 | http://scripts.sil.org/OFL 10 | 11 | ----------------------------------------------------------- 12 | SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 13 | ----------------------------------------------------------- 14 | 15 | PREAMBLE 16 | The goals of the Open Font License (OFL) are to stimulate worldwide 17 | development of collaborative font projects, to support the font creation 18 | efforts of academic and linguistic communities, and to provide a free and 19 | open framework in which fonts may be shared and improved in partnership 20 | with others. 21 | 22 | The OFL allows the licensed fonts to be used, studied, modified and 23 | redistributed freely as long as they are not sold by themselves. The 24 | fonts, including any derivative works, can be bundled, embedded, 25 | redistributed and/or sold with any software provided that any reserved 26 | names are not used by derivative works. The fonts and derivatives, 27 | however, cannot be released under any other type of license. The 28 | requirement for fonts to remain under this license does not apply 29 | to any document created using the fonts or their derivatives. 30 | 31 | DEFINITIONS 32 | "Font Software" refers to the set of files released by the Copyright 33 | Holder(s) under this license and clearly marked as such. This may 34 | include source files, build scripts and documentation. 35 | 36 | "Reserved Font Name" refers to any names specified as such after the 37 | copyright statement(s). 38 | 39 | "Original Version" refers to the collection of Font Software components as 40 | distributed by the Copyright Holder(s). 41 | 42 | "Modified Version" refers to any derivative made by adding to, deleting, 43 | or substituting -- in part or in whole -- any of the components of the 44 | Original Version, by changing formats or by porting the Font Software to a 45 | new environment. 46 | 47 | "Author" refers to any designer, engineer, programmer, technical 48 | writer or other person who contributed to the Font Software. 49 | 50 | PERMISSION & CONDITIONS 51 | Permission is hereby granted, free of charge, to any person obtaining 52 | a copy of the Font Software, to use, study, copy, merge, embed, modify, 53 | redistribute, and sell modified and unmodified copies of the Font 54 | Software, subject to the following conditions: 55 | 56 | 1) Neither the Font Software nor any of its individual components, 57 | in Original or Modified Versions, may be sold by itself. 58 | 59 | 2) Original or Modified Versions of the Font Software may be bundled, 60 | redistributed and/or sold with any software, provided that each copy 61 | contains the above copyright notice and this license. These can be 62 | included either as stand-alone text files, human-readable headers or 63 | in the appropriate machine-readable metadata fields within text or 64 | binary files as long as those fields can be easily viewed by the user. 65 | 66 | 3) No Modified Version of the Font Software may use the Reserved Font 67 | Name(s) unless explicit written permission is granted by the corresponding 68 | Copyright Holder. This restriction only applies to the primary font name as 69 | presented to the users. 70 | 71 | 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font 72 | Software shall not be used to promote, endorse or advertise any 73 | Modified Version, except to acknowledge the contribution(s) of the 74 | Copyright Holder(s) and the Author(s) or with their explicit written 75 | permission. 76 | 77 | 5) The Font Software, modified or unmodified, in part or in whole, 78 | must be distributed entirely under this license, and must not be 79 | distributed under any other license. The requirement for fonts to 80 | remain under this license does not apply to any document created 81 | using the Font Software. 82 | 83 | TERMINATION 84 | This license becomes null and void if any of the above conditions are 85 | not met. 86 | 87 | DISCLAIMER 88 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 89 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF 90 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 91 | OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE 92 | COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 93 | INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL 94 | DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 95 | FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM 96 | OTHER DEALINGS IN THE FONT SOFTWARE. 97 | -------------------------------------------------------------------------------- /assets/readme.txt: -------------------------------------------------------------------------------- 1 | The symbols library contains graphical assets created using Flash CS5. -------------------------------------------------------------------------------- /assets/src/MaskedMovieClip.as: -------------------------------------------------------------------------------- 1 | /***************************************************** * * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. * ***************************************************** * The contents of this file are subject to the Mozilla Public License * Version 1.1 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * * The Initial Developer of the Original Code is Adobe Systems Incorporated. * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems * Incorporated. All Rights Reserved. * *****************************************************/ package { import flash.display.MovieClip; /** * Class forwards the masked width and height ove the symbol, * instead of the size that includes the unmasked portions of * the movie clip. */ public class MaskedMovieClip extends MovieClip { override public function get width():Number { return maskMovieClip.width; } override public function get height():Number { return maskMovieClip.height; } } } -------------------------------------------------------------------------------- /assets/src/MovieClipRow.as: -------------------------------------------------------------------------------- 1 | /***************************************************** * * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. * ***************************************************** * The contents of this file are subject to the Mozilla Public License * Version 1.1 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * * The Initial Developer of the Original Code is Adobe Systems Incorporated. * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems * Incorporated. All Rights Reserved. * *****************************************************/ package { import flash.utils.*; import flash.display.Sprite; import flash.events.Event; import flash.display.Stage; import flash.display.Graphics; import flash.display.MovieClip; import flash.display.IBitmapDrawable; import flash.display.BitmapData; import flash.geom.Matrix; import flash.display.DisplayObject; /** * Class takes a base symbol, and clones it a number of times in order * to reach the desired width. The surplus width gets masked out. */ public class MovieClipRow extends Sprite { public function MovieClipRow() { super(); var instanceName:String = getQualifiedClassName(this)+"Base";; if (hasOwnProperty(instanceName)) { base = this[instanceName] as MovieClip; base.visible = false; _mask = base.hasOwnProperty("maskMovieClip") ? base.maskMovieClip : base; addEventListener(Event.ENTER_FRAME, draw); _width = super.width; scaleX = 1; scaleY = 1; } } override public function set width(value:Number):void { if (value != _width) { _width = value; draw(); } } override public function get width():Number { return _width; } // Internals // private var base:MovieClip; private var _mask:DisplayObject; private var _width:Number; private var clones:Number; private function draw(event:Event = null):void { var bmpd:BitmapData = new BitmapData(_mask.width, _mask.height); bmpd.draw(base, null, null, null, _mask.getBounds(base)); graphics.clear(); graphics.beginBitmapFill(bmpd); graphics.drawRect(0, 0, _width, _mask.height); graphics.endFill(); } } } -------------------------------------------------------------------------------- /libs/OSMF.swc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erlyvideo/hlsplayer/d5b060883c89cd2e31ab243bb31b1c5fc158ffb0/libs/OSMF.swc -------------------------------------------------------------------------------- /libs/at/matthew/httpstreaming/HTTPStreamingH264NALU.as: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1 3 | * 4 | * The contents of this file are subject to the Mozilla Public License Version 5 | * 1.1 (the "License"); you may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * http://www.mozilla.org/MPL/ 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" basis, 10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing rights and limitations under the 12 | * License. 13 | * 14 | * The Original Code is the at.matthew.httpstreaming package. 15 | * 16 | * The Initial Developer of the Original Code is 17 | * Matthew Kaufman. 18 | * Portions created by the Initial Developer are Copyright (C) 2011 19 | * the Initial Developer. All Rights Reserved. 20 | * 21 | * Contributor(s): 22 | * 23 | * ***** END LICENSE BLOCK ***** */ 24 | 25 | package at.matthew.httpstreaming 26 | { 27 | import flash.utils.ByteArray; 28 | 29 | public class HTTPStreamingH264NALU 30 | { 31 | private var data:ByteArray; 32 | 33 | public function HTTPStreamingH264NALU(source:ByteArray):void 34 | { 35 | data = source; 36 | } 37 | 38 | public function get NALtype():uint 39 | { 40 | return data[0] & 0x1f; 41 | } 42 | 43 | public function get length():uint 44 | { 45 | return data.length; 46 | } 47 | 48 | public function get NALdata():ByteArray 49 | { 50 | return data; 51 | } 52 | 53 | } 54 | } -------------------------------------------------------------------------------- /libs/at/matthew/httpstreaming/HTTPStreamingM3U8Factory.as: -------------------------------------------------------------------------------- 1 | package at.matthew.httpstreaming { 2 | 3 | import org.osmf.media.MediaResourceBase; 4 | import org.osmf.media.URLResource; 5 | import org.osmf.net.httpstreaming.HTTPStreamingFactory; 6 | import org.osmf.net.httpstreaming.HTTPStreamingFileHandlerBase; 7 | import org.osmf.net.httpstreaming.HTTPStreamingIndexHandlerBase; 8 | import org.osmf.net.httpstreaming.HTTPStreamingIndexInfoBase; 9 | 10 | public class HTTPStreamingM3U8Factory extends HTTPStreamingFactory { 11 | 12 | override public function createFileHandler(resource:MediaResourceBase):HTTPStreamingFileHandlerBase { 13 | return new HTTPStreamingMP2TSFileHandler(); 14 | } 15 | 16 | override public function createIndexHandler(resource:MediaResourceBase, fileHandler:HTTPStreamingFileHandlerBase):HTTPStreamingIndexHandlerBase { 17 | return new HTTPStreamingM3U8IndexHandler(); 18 | } 19 | 20 | override public function createIndexInfo(resource:MediaResourceBase):HTTPStreamingIndexInfoBase { 21 | return M3U8Utils.createM3U8IndexInfo(resource as URLResource); 22 | } 23 | 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /libs/at/matthew/httpstreaming/HTTPStreamingM3U8IndexItem.as: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1 3 | * 4 | * The contents of this file are subject to the Mozilla Public License Version 5 | * 1.1 (the "License"); you may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * http://www.mozilla.org/MPL/ 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" basis, 10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing rights and limitations under the 12 | * License. 13 | * 14 | * The Original Code is the at.matthew.httpstreaming package. 15 | * 16 | * The Initial Developer of the Original Code is 17 | * Matthew Kaufman. 18 | * Portions created by the Initial Developer are Copyright (C) 2011 19 | * the Initial Developer. All Rights Reserved. 20 | * 21 | * Contributor(s): 22 | * 23 | * ***** END LICENSE BLOCK ***** */ 24 | 25 | package at.matthew.httpstreaming 26 | { 27 | internal class HTTPStreamingM3U8IndexItem 28 | { 29 | private var _duration:Number; 30 | private var _url:String; 31 | private var _startTime:Number; 32 | 33 | public function HTTPStreamingM3U8IndexItem(duration:Number, url:String) 34 | { 35 | _duration = duration; 36 | _url = url; 37 | } 38 | 39 | public function set startTime(time:Number):void 40 | { 41 | _startTime = time; 42 | } 43 | 44 | public function get startTime():Number 45 | { 46 | return _startTime; 47 | } 48 | 49 | public function get duration():Number 50 | { 51 | return _duration; 52 | } 53 | 54 | public function get url():String 55 | { 56 | return _url; 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /libs/at/matthew/httpstreaming/HTTPStreamingM3U8IndexRateItem.as: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1 3 | * 4 | * The contents of this file are subject to the Mozilla Public License Version 5 | * 1.1 (the "License"); you may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * http://www.mozilla.org/MPL/ 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" basis, 10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing rights and limitations under the 12 | * License. 13 | * 14 | * The Original Code is the at.matthew.httpstreaming package. 15 | * 16 | * The Initial Developer of the Original Code is 17 | * Matthew Kaufman. 18 | * Portions created by the Initial Developer are Copyright (C) 2011 19 | * the Initial Developer. All Rights Reserved. 20 | * 21 | * Contributor(s): 22 | * 23 | * ***** END LICENSE BLOCK ***** */ 24 | 25 | package at.matthew.httpstreaming 26 | { 27 | import __AS3__.vec.Vector; 28 | 29 | internal class HTTPStreamingM3U8IndexRateItem 30 | { 31 | private var _bw:Number; 32 | private var _url:String; 33 | private var _manifest:Vector.; 34 | private var _totalTime:Number; 35 | private var _sequenceNumber:int; // Stores the #EXT-X-MEDIA-SEQUENCE value for the current manifest (needed for live streaming) 36 | private var _live:Boolean; 37 | 38 | public function HTTPStreamingM3U8IndexRateItem(bw:Number = 0, url:String = null, seqNum:int = 0, live:Boolean = true) // Live is true for all streams until we get a #EXT-X-ENDLIST tag 39 | { 40 | _bw = bw; 41 | _url = url; 42 | _manifest = new Vector.; 43 | _totalTime = 0; 44 | _sequenceNumber = seqNum; 45 | _live = live; 46 | } 47 | 48 | public function get bw():Number 49 | { 50 | return _bw; 51 | } 52 | 53 | public function get url():String 54 | { 55 | return _url; 56 | } 57 | 58 | public function get live():Boolean 59 | { 60 | return _live; 61 | } 62 | 63 | public function get urlBase():String 64 | { 65 | var offset:int; 66 | offset = _url.lastIndexOf("/"); 67 | return _url.substr(0, offset+1); 68 | } 69 | 70 | public function get totalTime():Number 71 | { 72 | return _totalTime; 73 | } 74 | 75 | public function get sequenceNumber():int 76 | { 77 | return _sequenceNumber; 78 | } 79 | 80 | public function set sequenceNumber(seqNum:int):void 81 | { 82 | _sequenceNumber = seqNum; 83 | } 84 | 85 | public function set live(live:Boolean):void 86 | { 87 | _live = live; 88 | } 89 | 90 | public function addIndexItem(item:HTTPStreamingM3U8IndexItem):void 91 | { 92 | item.startTime = _totalTime; 93 | _totalTime += item.duration; 94 | _manifest.push(item); 95 | } 96 | 97 | public function clearManifest():void 98 | { 99 | _manifest = new Vector.; 100 | _totalTime = 0; 101 | } 102 | 103 | public static function sortComparison(item1:HTTPStreamingM3U8IndexRateItem, item2:HTTPStreamingM3U8IndexRateItem):Number 104 | { 105 | return item1._bw - item2._bw; 106 | } 107 | 108 | public function get manifest():Vector. 109 | { 110 | return _manifest; 111 | } 112 | 113 | } 114 | } -------------------------------------------------------------------------------- /libs/at/matthew/httpstreaming/HTTPStreamingM3U8NetLoader.as: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1 3 | * 4 | * The contents of this file are subject to the Mozilla Public License Version 5 | * 1.1 (the "License"); you may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * http://www.mozilla.org/MPL/ 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" basis, 10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing rights and limitations under the 12 | * License. 13 | * 14 | * The Original Code is the at.matthew.httpstreaming package. 15 | * 16 | * The Initial Developer of the Original Code is 17 | * Matthew Kaufman. 18 | * Portions created by the Initial Developer are Copyright (C) 2011 19 | * the Initial Developer. All Rights Reserved. 20 | * 21 | * Contributor(s): 22 | * 23 | * ***** END LICENSE BLOCK ***** */ 24 | 25 | package at.matthew.httpstreaming { 26 | 27 | import org.osmf.media.MediaResourceBase; 28 | import org.osmf.net.httpstreaming.HTTPStreamingFactory; 29 | import org.osmf.net.httpstreaming.HTTPStreamingNetLoader; 30 | 31 | public class HTTPStreamingM3U8NetLoader extends HTTPStreamingNetLoader { 32 | 33 | override public function canHandleResource(resource:MediaResourceBase):Boolean { 34 | return resource.getMetadataValue(M3U8Metadata.M3U8_METADATA) != null; 35 | } 36 | 37 | override protected function createHTTPStreamingFactory():HTTPStreamingFactory { 38 | return new HTTPStreamingM3U8Factory(); 39 | } 40 | 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /libs/at/matthew/httpstreaming/HTTPStreamingM3U8NetLoaderAdapter.as: -------------------------------------------------------------------------------- 1 | package at.matthew.httpstreaming { 2 | 3 | import org.osmf.media.MediaResourceBase; 4 | import org.osmf.net.HTTPStreamingNetLoaderAdapter; 5 | import org.osmf.net.PlaybackOptimizationManager; 6 | import org.osmf.net.httpstreaming.HTTPStreamingFactory; 7 | 8 | public class HTTPStreamingM3U8NetLoaderAdapter extends HTTPStreamingNetLoaderAdapter { 9 | 10 | public function HTTPStreamingM3U8NetLoaderAdapter(playbackOptimizationManager:PlaybackOptimizationManager) { 11 | super(playbackOptimizationManager); 12 | } 13 | 14 | override public function canHandleResource(resource:MediaResourceBase):Boolean { 15 | return resource.getMetadataValue(M3U8Metadata.M3U8_METADATA) != null; 16 | } 17 | 18 | override protected function createHTTPStreamingFactory():HTTPStreamingFactory { 19 | return new HTTPStreamingM3U8Factory(); 20 | } 21 | 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /libs/at/matthew/httpstreaming/HTTPStreamingMP2PESBase.as: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1 3 | * 4 | * The contents of this file are subject to the Mozilla Public License Version 5 | * 1.1 (the "License"); you may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * http://www.mozilla.org/MPL/ 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" basis, 10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing rights and limitations under the 12 | * License. 13 | * 14 | * The Original Code is the at.matthew.httpstreaming package. 15 | * 16 | * The Initial Developer of the Original Code is 17 | * Matthew Kaufman. 18 | * Portions created by the Initial Developer are Copyright (C) 2011 19 | * the Initial Developer. All Rights Reserved. 20 | * 21 | * Contributor(s): 22 | * 23 | * ***** END LICENSE BLOCK ***** */ 24 | 25 | package at.matthew.httpstreaming 26 | { 27 | import flash.utils.ByteArray; 28 | 29 | internal class HTTPStreamingMP2PESBase 30 | { 31 | 32 | public static var firstTimestamp:Number; 33 | 34 | protected var _timestamp:Number; 35 | protected var _compositionTime:Number; 36 | 37 | 38 | public function processES(pusi:Boolean, packet:ByteArray, flush:Boolean = false):ByteArray 39 | { 40 | return null; 41 | } 42 | } 43 | 44 | 45 | 46 | } -------------------------------------------------------------------------------- /libs/at/matthew/httpstreaming/M3U8Element.as: -------------------------------------------------------------------------------- 1 | package at.matthew.httpstreaming { 2 | 3 | import org.osmf.elements.LoadFromDocumentElement; 4 | import org.osmf.media.MediaResourceBase; 5 | import org.osmf.traits.LoaderBase; 6 | 7 | public class M3U8Element extends LoadFromDocumentElement { 8 | 9 | public function M3U8Element(resource:MediaResourceBase=null, loader:LoaderBase=null) { 10 | if (loader == null) { 11 | loader = new M3U8Loader(); 12 | } 13 | super(resource, loader); 14 | } 15 | 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /libs/at/matthew/httpstreaming/M3U8IndexInfo.as: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1 3 | * 4 | * The contents of this file are subject to the Mozilla Public License Version 5 | * 1.1 (the "License"); you may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * http://www.mozilla.org/MPL/ 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" basis, 10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing rights and limitations under the 12 | * License. 13 | * 14 | * The Original Code is the at.matthew.httpstreaming package. 15 | * 16 | * The Initial Developer of the Original Code is 17 | * Matthew Kaufman. 18 | * Portions created by the Initial Developer are Copyright (C) 2011 19 | * the Initial Developer. All Rights Reserved. 20 | * 21 | * Contributor(s): 22 | * 23 | * ***** END LICENSE BLOCK ***** */ 24 | 25 | package at.matthew.httpstreaming { 26 | 27 | import org.osmf.net.httpstreaming.HTTPStreamingIndexInfoBase; 28 | 29 | public class M3U8IndexInfo extends HTTPStreamingIndexInfoBase { 30 | 31 | private var _baseUrl:String; 32 | private var _streamInfos:Vector.; 33 | 34 | public function M3U8IndexInfo(baseUrl:String, streamInfos:Vector.=null) { 35 | _baseUrl = baseUrl; 36 | _streamInfos = streamInfos; 37 | } 38 | 39 | public function get baseUrl():String { return _baseUrl } 40 | public function get streamInfos():Vector. { return _streamInfos } 41 | 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /libs/at/matthew/httpstreaming/M3U8Metadata.as: -------------------------------------------------------------------------------- 1 | package at.matthew.httpstreaming { 2 | 3 | import org.osmf.metadata.Metadata; 4 | 5 | public class M3U8Metadata extends Metadata { 6 | 7 | public static const M3U8_METADATA:String = "m3u8Metadata"; 8 | 9 | public function M3U8Metadata() { 10 | } 11 | 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /libs/at/matthew/httpstreaming/M3U8StreamInfo.as: -------------------------------------------------------------------------------- 1 | package at.matthew.httpstreaming { 2 | 3 | public class M3U8StreamInfo { 4 | 5 | private var _streamName:String; 6 | private var _bitrate:Number; 7 | private var _metadata:Object; 8 | 9 | public function M3U8StreamInfo(streamName:String, bitrate:Number, metadata:Object) { 10 | _streamName = streamName; 11 | _bitrate = bitrate; 12 | _metadata = metadata; 13 | } 14 | 15 | public function get streamName():String { return _streamName } 16 | public function get bitrate():Number { return _bitrate } 17 | public function get metadata():Object { return _metadata } 18 | 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /libs/at/matthew/httpstreaming/M3U8Utils.as: -------------------------------------------------------------------------------- 1 | package at.matthew.httpstreaming { 2 | 3 | import org.osmf.media.URLResource; 4 | import org.osmf.net.DynamicStreamingItem; 5 | import org.osmf.net.DynamicStreamingResource; 6 | import org.osmf.metadata.MetadataNamespaces; 7 | 8 | public class M3U8Utils { 9 | 10 | public static function getBaseUrl(url:String):String { 11 | if (url.lastIndexOf("/") >= 0) { 12 | url = url.substr(0, url.lastIndexOf("/") + 1); 13 | } else { 14 | url = ""; 15 | } 16 | return url; 17 | } 18 | 19 | public static function createM3U8IndexInfo(resource:URLResource):M3U8IndexInfo { 20 | var baseUrl:String = ""; 21 | var streamInfos:Vector. = new Vector.(); 22 | 23 | if (resource is DynamicStreamingResource) { 24 | var dsResource:DynamicStreamingResource = resource as DynamicStreamingResource; 25 | var streamInfo:M3U8StreamInfo; 26 | var metadata:Object; 27 | for each (var dynItem:DynamicStreamingItem in dsResource.streamItems) { 28 | metadata = new Object(); 29 | if (dynItem.width > 0) metadata.width = dynItem.width; 30 | if (dynItem.height > 0) metadata.height = dynItem.height; 31 | streamInfo = new M3U8StreamInfo(dynItem.streamName, dynItem.bitrate, metadata); 32 | streamInfos.push(streamInfo); 33 | } 34 | baseUrl = dsResource.host; 35 | } else { 36 | streamInfos.push(new M3U8StreamInfo(resource.url, 0, {})); 37 | } 38 | 39 | return new M3U8IndexInfo(baseUrl, streamInfos); 40 | } 41 | 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/org/osmf/net/HTTPStreamingNetLoaderAdapter.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | **********************************************************/ 19 | 20 | package org.osmf.net 21 | { 22 | import flash.events.NetStatusEvent; 23 | import flash.net.NetConnection; 24 | import flash.net.NetStream; 25 | 26 | import org.osmf.events.*; 27 | import org.osmf.media.URLResource; 28 | import org.osmf.net.httpstreaming.*; 29 | import org.osmf.net.rtmpstreaming.DroppedFramesRule; 30 | import org.osmf.net.httpstreaming.f4f.*; 31 | /** 32 | * PlaybackOptimization adapter for RTMPDynamicStreamingNetLoader. 33 | */ 34 | public class HTTPStreamingNetLoaderAdapter extends HTTPStreamingNetLoader 35 | { 36 | /** 37 | * Constructor. 38 | */ 39 | public function HTTPStreamingNetLoaderAdapter(playbackOptimizationManager:PlaybackOptimizationManager) 40 | { 41 | this.playbackOptimizationManager = playbackOptimizationManager; 42 | super(); 43 | } 44 | 45 | /** 46 | * @private 47 | * 48 | * Overridden to allow the creation of a NetStreamSwitchManager object. 49 | * 50 | * @langversion 3.0 51 | * @playerversion Flash 10 52 | * @playerversion AIR 1.5 53 | * @productversion OSMF 1.0 54 | */ 55 | override protected function createNetStreamSwitchManager(connection:NetConnection, netStream:NetStream, dsResource:DynamicStreamingResource):NetStreamSwitchManagerBase 56 | { 57 | playbackOptimizationManager.optimizePlayback(connection, netStream, dsResource); 58 | netStream.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus); 59 | return super.createNetStreamSwitchManager(connection, netStream, dsResource); 60 | } 61 | 62 | // Internals 63 | // 64 | private function onNetStatus(event:NetStatusEvent):void 65 | { 66 | var netStream:NetStream = event.currentTarget as NetStream; 67 | if (event.info.code == NetStreamCodes.NETSTREAM_BUFFER_EMPTY) 68 | { 69 | if (netStream.bufferTime >= 2.0) 70 | { 71 | netStream.bufferTime += 1.0; 72 | } 73 | else 74 | { 75 | netStream.bufferTime = 2.0; 76 | } 77 | } 78 | } 79 | 80 | private var playbackOptimizationManager:PlaybackOptimizationManager; 81 | } 82 | } -------------------------------------------------------------------------------- /src/org/osmf/net/MulticastNetLoaderAdapter.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | **********************************************************/ 19 | 20 | package org.osmf.net 21 | { 22 | import flash.net.NetConnection; 23 | import flash.net.NetStream; 24 | 25 | import org.osmf.traits.LoadTrait; 26 | 27 | /** 28 | * 29 | */ 30 | public class MulticastNetLoaderAdapter extends MulticastNetLoader 31 | { 32 | public function MulticastNetLoaderAdapter(playbackOptimizationManager:PlaybackOptimizationManager, factory:NetConnectionFactoryBase = null) 33 | { 34 | this.playbackOptimizationManager = playbackOptimizationManager; 35 | super(factory); 36 | } 37 | 38 | /** 39 | * @private 40 | * 41 | * Overridden to allow the creation of a NetStreamSwitchManager object. 42 | * 43 | * @langversion 3.0 44 | * @playerversion Flash 10 45 | * @playerversion AIR 1.5 46 | * @productversion OSMF 1.0 47 | */ 48 | override protected function createNetStreamSwitchManager(connection:NetConnection, netStream:NetStream, dsResource:DynamicStreamingResource):NetStreamSwitchManagerBase 49 | { 50 | playbackOptimizationManager.optimizePlayback(connection, netStream, dsResource); 51 | // if (dsResource != null) 52 | // { 53 | // var metrics:RTMPNetStreamMetrics = new RTMPNetStreamMetrics(netStream); 54 | // var streamType:String = dsResource.getMetadataValue("streamType") as String; 55 | // return new StrobeNetStreamSwitchManager(connection, netStream, dsResource, metrics, getDefaultSwitchingRules(metrics, streamType)); 56 | // } 57 | return null; 58 | } 59 | 60 | private var playbackOptimizationManager:PlaybackOptimizationManager; 61 | } 62 | } -------------------------------------------------------------------------------- /src/org/osmf/net/RTMPDynamicStreamingNetLoaderAdapter.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | **********************************************************/ 19 | 20 | package org.osmf.net 21 | { 22 | import flash.net.NetConnection; 23 | import flash.net.NetStream; 24 | 25 | import org.osmf.net.rtmpstreaming.DroppedFramesRule; 26 | import org.osmf.net.rtmpstreaming.InsufficientBandwidthRule; 27 | import org.osmf.net.rtmpstreaming.InsufficientBufferRule; 28 | import org.osmf.net.rtmpstreaming.RTMPDynamicStreamingNetLoader; 29 | import org.osmf.net.rtmpstreaming.RTMPNetStreamMetrics; 30 | import org.osmf.net.rtmpstreaming.SufficientBandwidthRule; 31 | 32 | /** 33 | * PlaybackOptimization adapter for RTMPDynamicStreamingNetLoader. 34 | */ 35 | public class RTMPDynamicStreamingNetLoaderAdapter extends RTMPDynamicStreamingNetLoader 36 | { 37 | /** 38 | * Constructor 39 | */ 40 | public function RTMPDynamicStreamingNetLoaderAdapter(playbackOptimizationManager:PlaybackOptimizationManager, factory:NetConnectionFactoryBase = null) 41 | { 42 | this.playbackOptimizationManager = playbackOptimizationManager; 43 | super(factory); 44 | } 45 | 46 | /** 47 | * @private 48 | * 49 | * Overridden to allow the creation of a NetStreamSwitchManager object. 50 | * 51 | * @langversion 3.0 52 | * @playerversion Flash 10 53 | * @playerversion AIR 1.5 54 | * @productversion OSMF 1.0 55 | */ 56 | override protected function createNetStreamSwitchManager(connection:NetConnection, netStream:NetStream, dsResource:DynamicStreamingResource):NetStreamSwitchManagerBase 57 | { 58 | playbackOptimizationManager.optimizePlayback(connection, netStream, dsResource); 59 | if (dsResource != null) 60 | { 61 | var metrics:RTMPNetStreamMetrics = new RTMPNetStreamMetrics(netStream); 62 | var streamType:String = dsResource.getMetadataValue("streamType") as String; 63 | return new StrobeNetStreamSwitchManager(connection, netStream, dsResource, metrics, getDefaultSwitchingRules(metrics, streamType)); 64 | } 65 | return null; 66 | } 67 | 68 | // Internals 69 | // 70 | private function getDefaultSwitchingRules(metrics:RTMPNetStreamMetrics, streamType:String):Vector. 71 | { 72 | var rules:Vector. = new Vector.(); 73 | 74 | rules.push(new SufficientBandwidthRule(metrics)); 75 | rules.push(new InsufficientBandwidthRule(metrics)); 76 | rules.push(new DroppedFramesRule(metrics)); 77 | rules.push(new InsufficientBufferRule(metrics)); 78 | return rules; 79 | } 80 | 81 | private var playbackOptimizationManager:PlaybackOptimizationManager; 82 | } 83 | } -------------------------------------------------------------------------------- /src/org/osmf/net/RunningAverage.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | **********************************************************/ 19 | 20 | package org.osmf.net 21 | { 22 | import flash.net.NetStream; 23 | 24 | /** 25 | * @private 26 | */ 27 | internal class RunningAverage 28 | { 29 | public function RunningAverage(sampleCount:int) 30 | { 31 | this.sampleCount = sampleCount; 32 | } 33 | 34 | public function get average():Number 35 | { 36 | return _average; 37 | } 38 | 39 | public function addSample(value:Number):void 40 | { 41 | if (isNaN(value)) 42 | { 43 | return; 44 | } 45 | 46 | samples.unshift(value); 47 | if (samples.length > sampleCount) 48 | { 49 | samples.pop(); 50 | } 51 | 52 | var total:Number = 0; 53 | for (var b:uint = 0; b < samples.length; b++) 54 | { 55 | total += samples[b]; 56 | } 57 | _average = total / samples.length; 58 | } 59 | 60 | public function addDeltaTimeRatioSample(value:Number, time:Number):void 61 | { 62 | var timeDelta:Number = time - previousTimestamp; 63 | if (timeDelta > 0) 64 | { 65 | addSample((value - previousValue) / timeDelta); 66 | } 67 | previousTimestamp = time; 68 | previousValue = value; 69 | } 70 | 71 | public function clearSamples():void 72 | { 73 | samples = new Array(); 74 | } 75 | 76 | private var previousTimestamp:Number = NaN; 77 | private var previousValue:Number = NaN; 78 | private var samples:Array = new Array(); 79 | private var sampleCount:int; 80 | private var _average:Number; 81 | } 82 | } -------------------------------------------------------------------------------- /src/org/osmf/player/chrome/IControlBar.as: -------------------------------------------------------------------------------- 1 | package org.osmf.player.chrome{ 2 | import flash.events.IEventDispatcher; 3 | 4 | import org.osmf.layout.ILayoutTarget; 5 | import org.osmf.media.MediaElement; 6 | import org.osmf.player.chrome.assets.AssetsManager; 7 | 8 | /** 9 | * IControlBar 10 | * @author johncblandii 11 | */ 12 | public interface IControlBar extends ILayoutTarget, IEventDispatcher{ 13 | // PROPERTIES 14 | // 15 | function get width():Number; function set width(value:Number):void; 16 | function get height():Number; function set height(value:Number):void; 17 | function get autoHide():Boolean; function set autoHide(value:Boolean):void; 18 | function get autoHideTimeout():int; function set autoHideTimeout(value:int):void; 19 | function get media():MediaElement; function set media(value:MediaElement):void; 20 | function get tintColor():uint; function set tintColor(value:uint):void; 21 | function get visible():Boolean; function set visible(value:Boolean):void; 22 | 23 | // FUNCTIONS 24 | // 25 | function configure(xml:XML, assetManager:AssetsManager):void; 26 | } 27 | } -------------------------------------------------------------------------------- /src/org/osmf/player/chrome/VolumeControlBar.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2011 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | * 19 | **********************************************************/ 20 | 21 | package org.osmf.player.chrome{ 22 | import org.osmf.layout.HorizontalAlign; 23 | import org.osmf.layout.LayoutMode; 24 | import org.osmf.layout.VerticalAlign; 25 | import org.osmf.media.MediaElement; 26 | import org.osmf.player.chrome.assets.AssetIDs; 27 | import org.osmf.player.chrome.assets.AssetsManager; 28 | import org.osmf.player.chrome.widgets.AutoHideWidget; 29 | import org.osmf.player.chrome.widgets.MuteButton; 30 | import org.osmf.player.chrome.widgets.VolumeWidget; 31 | import org.osmf.player.chrome.widgets.Widget; 32 | import org.osmf.player.chrome.widgets.WidgetIDs; 33 | import org.osmf.traits.MediaTraitType; 34 | 35 | /** 36 | * MobileControlBar 37 | * @author johncblandii 38 | */ 39 | public class VolumeControlBar extends AutoHideWidget implements IControlBar 40 | { 41 | // OVERRIDES 42 | // 43 | 44 | override public function configure(xml:XML, assetManager:AssetsManager):void 45 | { 46 | //id = WidgetIDs; 47 | face = AssetIDs.VOLUME_BAR_BACKDROP; 48 | fadeSteps = 6; 49 | 50 | layoutMetadata.horizontalAlign = HorizontalAlign.CENTER; 51 | layoutMetadata.verticalAlign = VerticalAlign.TOP; 52 | layoutMetadata.layoutMode = LayoutMode.HORIZONTAL; 53 | super.configure(xml, assetManager); 54 | 55 | // Mute/unmute 56 | var muteButton:MuteButton = new MuteButton(false); 57 | muteButton.id = WidgetIDs.MUTE_BUTTON; 58 | muteButton.volumeSteps = 1; 59 | muteButton.layoutMetadata.verticalAlign = VerticalAlign.MIDDLE; 60 | muteButton.layoutMetadata.horizontalAlign = HorizontalAlign.RIGHT; 61 | addChildWidget(muteButton); 62 | 63 | var separator:Widget = new Widget(); 64 | separator.face = AssetIDs.VOLUME_BAR_BUTTON_SEPARATOR; 65 | addChildWidget(separator); 66 | 67 | volumeWidget = new VolumeWidget(); 68 | volumeWidget.layoutMetadata.layoutMode = LayoutMode.HORIZONTAL; 69 | volumeWidget.layoutMetadata.width = layoutMetadata.width; 70 | addChildWidget(volumeWidget); 71 | 72 | //muteButton.volumeWidget = volumeWidget; 73 | 74 | // Configure 75 | configureWidgets([muteButton, separator, volumeWidget]); 76 | 77 | measure(); 78 | } 79 | 80 | override public function set media(value:MediaElement):void{ 81 | if(value != null){ 82 | super.media = value; 83 | if(volumeWidget) 84 | volumeWidget.media = value; 85 | } 86 | } 87 | 88 | // INTERNALS 89 | // 90 | 91 | private function configureWidgets(widgets:Array):void 92 | { 93 | for each( var widget:Widget in widgets) 94 | { 95 | if (widget) 96 | { 97 | widget.configure(, assetManager); 98 | } 99 | } 100 | } 101 | 102 | private var volumeWidget:VolumeWidget; 103 | private static const _requiredTraits:Vector. = new Vector.; 104 | _requiredTraits[0] = MediaTraitType.AUDIO; 105 | } 106 | } -------------------------------------------------------------------------------- /src/org/osmf/player/chrome/assets/Asset.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | **********************************************************/ 19 | 20 | package org.osmf.player.chrome.assets 21 | { 22 | public class Asset 23 | { 24 | } 25 | } -------------------------------------------------------------------------------- /src/org/osmf/player/chrome/assets/AssetResource.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | **********************************************************/ 19 | 20 | package org.osmf.player.chrome.assets 21 | { 22 | public class AssetResource 23 | { 24 | public function AssetResource(id:String, url:String, local:Boolean) 25 | { 26 | _id = id; 27 | _url = url; 28 | _local = local; 29 | } 30 | 31 | public function get id():String 32 | { 33 | return _id; 34 | } 35 | 36 | public function get url():String 37 | { 38 | return _url; 39 | } 40 | 41 | public function get local():Boolean 42 | { 43 | return _local; 44 | } 45 | 46 | private var _id:String; 47 | private var _url:String; 48 | private var _local:Boolean; 49 | } 50 | } -------------------------------------------------------------------------------- /src/org/osmf/player/chrome/assets/AssetsManager.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | **********************************************************/ 19 | 20 | package org.osmf.player.chrome.assets 21 | { 22 | import flash.display.DisplayObject; 23 | import flash.events.Event; 24 | import flash.events.EventDispatcher; 25 | import flash.events.IOErrorEvent; 26 | import flash.utils.Dictionary; 27 | 28 | import org.osmf.player.chrome.configuration.AssetsParser; 29 | 30 | [Event(name="complete", type="flash.events.Event")] 31 | 32 | public class AssetsManager extends EventDispatcher 33 | { 34 | // Public API 35 | // 36 | 37 | public function AssetsManager() 38 | { 39 | loaders = new Dictionary(); 40 | resourceByLoader = new Dictionary(); 41 | } 42 | 43 | public function addConfigurationAssets(xml:XML):void 44 | { 45 | var parser:AssetsParser = new AssetsParser(); 46 | parser.parse(xml.assets, this); 47 | } 48 | 49 | public function addAsset(resource:AssetResource, loader:AssetLoader):void 50 | { 51 | var currentLoader:AssetLoader = getLoader(resource.id); 52 | if (currentLoader != null) 53 | { 54 | // Skip the addition: there's an asset present for the ID already. 55 | } 56 | else 57 | { 58 | assetCount++; 59 | 60 | loaders[resource] = loader; 61 | resourceByLoader[loader] = resource; 62 | } 63 | } 64 | 65 | public function getResource(loader:AssetLoader):AssetResource 66 | { 67 | return resourceByLoader[loader]; 68 | } 69 | 70 | public function getLoader(id:String):AssetLoader 71 | { 72 | var result:AssetLoader; 73 | 74 | for each (var resource:AssetResource in resourceByLoader) 75 | { 76 | if (resource.id == id) 77 | { 78 | result = loaders[resource] 79 | break; 80 | } 81 | } 82 | 83 | return result; 84 | } 85 | 86 | public function getAsset(id:String):Asset 87 | { 88 | var loader:AssetLoader = getLoader(id); 89 | return loader ? loader.asset : null; 90 | } 91 | 92 | public function getDisplayObject(id:String):DisplayObject 93 | { 94 | var result:DisplayObject; 95 | var asset:DisplayObjectAsset = getAsset(id) as DisplayObjectAsset; 96 | if (asset) 97 | { 98 | result = asset.displayObject; 99 | } 100 | return result; 101 | } 102 | 103 | public function load():void 104 | { 105 | completionCount = assetCount; 106 | for each (var loader:AssetLoader in loaders) 107 | { 108 | loader.addEventListener(Event.COMPLETE, onAssetLoaderComplete); 109 | loader.load(resourceByLoader[loader]); 110 | } 111 | } 112 | 113 | // Internals 114 | // 115 | 116 | private var loaders:Dictionary; 117 | private var resourceByLoader:Dictionary; 118 | 119 | private var assetCount:int = 0; 120 | private var _completionCount:int = -1; 121 | 122 | private function set completionCount(value:int):void 123 | { 124 | if (_completionCount != value) 125 | { 126 | _completionCount = value; 127 | if (_completionCount == 0) 128 | { 129 | dispatchEvent(new Event(Event.COMPLETE)); 130 | } 131 | } 132 | } 133 | private function get completionCount():int 134 | { 135 | return _completionCount; 136 | } 137 | 138 | private function onAssetLoaderComplete(event:Event):void 139 | { 140 | var loader:AssetLoader = event.target as AssetLoader; 141 | var resource:AssetResource = resourceByLoader[event.target]; 142 | 143 | completionCount--; 144 | } 145 | 146 | private function onAssetLoaderError(event:IOErrorEvent):void 147 | { 148 | var resource:AssetResource = resourceByLoader[event.target]; 149 | 150 | completionCount--; 151 | } 152 | } 153 | } -------------------------------------------------------------------------------- /src/org/osmf/player/chrome/assets/BitmapAsset.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | **********************************************************/ 19 | 20 | package org.osmf.player.chrome.assets 21 | { 22 | import flash.display.Bitmap; 23 | import flash.display.DisplayObject; 24 | import flash.geom.Rectangle; 25 | 26 | public class BitmapAsset extends DisplayObjectAsset 27 | { 28 | public function BitmapAsset(bitmap:Bitmap, scale9:Rectangle = null) 29 | { 30 | _bitmap = bitmap; 31 | _scale9 = scale9; 32 | super(); 33 | } 34 | 35 | override public function get displayObject():DisplayObject 36 | { 37 | return _scale9 38 | ? new Scale9Bitmap(_bitmap, _scale9) 39 | : new Bitmap(_bitmap.bitmapData.clone(), _bitmap.pixelSnapping, _bitmap.smoothing); 40 | } 41 | 42 | private var _bitmap:Bitmap; 43 | private var _scale9:Rectangle; 44 | 45 | } 46 | } -------------------------------------------------------------------------------- /src/org/osmf/player/chrome/assets/BitmapResource.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | **********************************************************/ 19 | 20 | package org.osmf.player.chrome.assets 21 | { 22 | import flash.geom.Rectangle; 23 | 24 | public class BitmapResource extends AssetResource 25 | { 26 | public function BitmapResource(id:String, url:String, local:Boolean, scale9:Rectangle) 27 | { 28 | _scale9 = scale9; 29 | 30 | super(id, url, local); 31 | } 32 | 33 | public function get scale9():Rectangle 34 | { 35 | return _scale9; 36 | } 37 | 38 | private var _scale9:Rectangle; 39 | } 40 | } -------------------------------------------------------------------------------- /src/org/osmf/player/chrome/assets/DisplayObjectAsset.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | **********************************************************/ 19 | 20 | package org.osmf.player.chrome.assets 21 | { 22 | import flash.display.DisplayObject; 23 | 24 | public class DisplayObjectAsset extends Asset 25 | { 26 | public function get displayObject():DisplayObject 27 | { 28 | return null; 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /src/org/osmf/player/chrome/assets/FontAsset.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | **********************************************************/ 19 | 20 | package org.osmf.player.chrome.assets 21 | { 22 | import flash.text.Font; 23 | import flash.text.TextFormat; 24 | import flash.text.TextFormatAlign; 25 | 26 | public class FontAsset extends SymbolAsset 27 | { 28 | public function FontAsset(font:Class, resource:FontResource) 29 | { 30 | super(font); 31 | 32 | _font = new font(); 33 | Font.registerFont(font); 34 | 35 | _resource = resource; 36 | } 37 | 38 | public function get font():Font 39 | { 40 | return _font; 41 | } 42 | 43 | public function get format():TextFormat 44 | { 45 | var result:TextFormat 46 | = new TextFormat 47 | ( _font.fontName 48 | , _resource.size 49 | , _resource.color 50 | , _resource.bold 51 | ); 52 | 53 | result.align = TextFormatAlign.LEFT; 54 | 55 | return result; 56 | } 57 | 58 | public function get resource():FontResource{ 59 | return _resource; 60 | } 61 | 62 | public function set resource(value:FontResource):void{ 63 | _resource = value; 64 | } 65 | 66 | private var _font:Font; 67 | private var _resource:FontResource; 68 | } 69 | } -------------------------------------------------------------------------------- /src/org/osmf/player/chrome/assets/FontResource.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | **********************************************************/ 19 | 20 | package org.osmf.player.chrome.assets 21 | { 22 | public class FontResource extends SymbolResource 23 | { 24 | public function FontResource 25 | ( id:String 26 | , url:String 27 | , local:Boolean 28 | , symbol:String 29 | , size:Number 30 | , color:uint 31 | , bold:Boolean=false 32 | ) 33 | { 34 | super(id, url, local, symbol); 35 | 36 | _size = size; 37 | _color = color; 38 | _bold = bold; 39 | } 40 | 41 | public function get size():Number 42 | { 43 | return _size; 44 | } 45 | 46 | public function set size(value:Number):void 47 | { 48 | _size = value; 49 | } 50 | 51 | public function get color():uint 52 | { 53 | return _color; 54 | } 55 | 56 | public function get bold():Boolean 57 | { 58 | return _bold; 59 | } 60 | 61 | // Internals 62 | // 63 | 64 | private var _size:Number; 65 | private var _color:uint; 66 | private var _bold:Boolean; 67 | } 68 | } -------------------------------------------------------------------------------- /src/org/osmf/player/chrome/assets/SWFAsset.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | **********************************************************/ 19 | 20 | package org.osmf.player.chrome.assets 21 | { 22 | import flash.display.DisplayObject; 23 | import flash.display.Loader; 24 | 25 | public class SWFAsset extends DisplayObjectAsset 26 | { 27 | public function SWFAsset(displayObject:DisplayObject) 28 | { 29 | _displayObject = displayObject; 30 | 31 | super(); 32 | } 33 | 34 | override public function get displayObject():DisplayObject 35 | { 36 | return _displayObject; 37 | } 38 | 39 | private var _displayObject:DisplayObject; 40 | } 41 | } -------------------------------------------------------------------------------- /src/org/osmf/player/chrome/assets/SymbolAsset.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | **********************************************************/ 19 | 20 | package org.osmf.player.chrome.assets 21 | { 22 | import flash.display.Bitmap; 23 | import flash.display.BitmapData; 24 | import flash.display.DisplayObject; 25 | import flash.display.InteractiveObject; 26 | 27 | public class SymbolAsset extends DisplayObjectAsset 28 | { 29 | public function SymbolAsset(type:Class) 30 | { 31 | _type = type; 32 | super(); 33 | } 34 | 35 | public function get type():Class 36 | { 37 | return _type; 38 | } 39 | 40 | override public function get displayObject():DisplayObject 41 | { 42 | var instance:* = new type(); 43 | if (instance is BitmapData) 44 | { 45 | instance = new Bitmap(instance); 46 | } 47 | return instance as DisplayObject; 48 | } 49 | private var _type:Class; 50 | } 51 | } -------------------------------------------------------------------------------- /src/org/osmf/player/chrome/assets/SymbolResource.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | **********************************************************/ 19 | 20 | package org.osmf.player.chrome.assets 21 | { 22 | public class SymbolResource extends AssetResource 23 | { 24 | public function SymbolResource(id:String, url:String, local:Boolean, symbol:String) 25 | { 26 | _symbol = symbol; 27 | 28 | super(id, url, local); 29 | } 30 | 31 | public function get symbol():String 32 | { 33 | return _symbol; 34 | } 35 | 36 | private var _symbol:String; 37 | 38 | } 39 | } -------------------------------------------------------------------------------- /src/org/osmf/player/chrome/configuration/AssetsParser.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | **********************************************************/ 19 | 20 | package org.osmf.player.chrome.configuration 21 | { 22 | import flash.errors.IllegalOperationError; 23 | import flash.geom.Rectangle; 24 | 25 | import org.osmf.player.chrome.assets.AssetLoader; 26 | import org.osmf.player.chrome.assets.AssetResource; 27 | import org.osmf.player.chrome.assets.AssetsManager; 28 | import org.osmf.player.chrome.assets.BitmapResource; 29 | import org.osmf.player.chrome.assets.FontResource; 30 | import org.osmf.player.chrome.assets.SymbolResource; 31 | 32 | public class AssetsParser 33 | { 34 | public function parse(assetsList:XMLList, assetsManager:AssetsManager):void 35 | { 36 | for each (var assets:XML in assetsList) 37 | { 38 | var baseURL:String = assets.@baseURL || ""; 39 | var loader:AssetLoader; 40 | var resource:AssetResource; 41 | for each (var asset:XML in assets.asset) 42 | { 43 | loader = new AssetLoader(); 44 | resource = assetToResource(asset, baseURL); 45 | if (loader && resource) 46 | { 47 | assetsManager.addAsset(resource, loader); 48 | } 49 | else 50 | { 51 | throw new IllegalOperationError("Unknown resource type", asset.@type); 52 | } 53 | } 54 | } 55 | } 56 | 57 | // Internals 58 | // 59 | 60 | private function assetToResource(asset:XML, baseURL:String = ""):AssetResource 61 | { 62 | var type:String = String(asset.@type || "").toLowerCase(); 63 | var resource:AssetResource; 64 | 65 | switch (type) 66 | { 67 | case "bitmapfile": 68 | case "embeddedbitmap": 69 | resource = new BitmapResource 70 | ( asset.@id 71 | , baseURL + asset.@url 72 | , type == "embeddedbitmap" 73 | , parseRect(asset.@scale9) 74 | ); 75 | break; 76 | 77 | case "fontsymbol": 78 | case "embeddedfont": 79 | resource = new FontResource 80 | ( asset.@id 81 | , baseURL + asset.@url 82 | , type == "embeddedfont" 83 | , asset.@symbol 84 | , parseInt(asset.@fontSize || "11") 85 | , parseInt(asset.@color || "0xFFFFFF") 86 | ); 87 | break; 88 | case "symbol": 89 | resource = new SymbolResource 90 | (asset.@id 91 | ,null 92 | ,true 93 | ,asset.@symbol 94 | ); 95 | } 96 | 97 | return resource; 98 | } 99 | 100 | private function parseRect(value:String):Rectangle 101 | { 102 | var result:Rectangle; 103 | 104 | var values:Array = value.split(","); 105 | if (values.length == 4) 106 | { 107 | result 108 | = new Rectangle 109 | ( parseInt(values[0]) 110 | , parseInt(values[1]) 111 | , parseInt(values[2]) 112 | , parseInt(values[3]) 113 | ); 114 | } 115 | 116 | return result; 117 | } 118 | } 119 | } -------------------------------------------------------------------------------- /src/org/osmf/player/chrome/configuration/Configuration.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | **********************************************************/ 19 | 20 | package org.osmf.player.chrome.configuration 21 | { 22 | import flash.events.Event; 23 | import flash.events.EventDispatcher; 24 | import flash.events.IOErrorEvent; 25 | import flash.net.URLLoader; 26 | import flash.net.URLRequest; 27 | 28 | import org.osmf.player.chrome.assets.AssetsManager; 29 | 30 | [Event(name="complete", type="flash.events.Event")] 31 | 32 | public class Configuration extends EventDispatcher 33 | { 34 | public function Configuration() 35 | { 36 | super(); 37 | } 38 | 39 | public function loadFromFile(url:String, loadAssets:Boolean):void 40 | { 41 | _configuration = null; 42 | 43 | var loader:URLLoader = new URLLoader(); 44 | loader.addEventListener 45 | ( IOErrorEvent.IO_ERROR 46 | , function(event:IOErrorEvent):void 47 | { 48 | trace("WARNING: configuration loading error:", event.text); 49 | dispatchEvent(new Event(Event.COMPLETE)); 50 | } 51 | ); 52 | loader.addEventListener 53 | ( Event.COMPLETE 54 | , function(event:Event):void 55 | { 56 | loadFromXML(new XML(loader.data), loadAssets); 57 | } 58 | ); 59 | loader.load(new URLRequest(url)); 60 | } 61 | 62 | public function loadFromXML(value:XML, loadAssets:Boolean):void 63 | { 64 | _configuration = value; 65 | if (loadAssets) 66 | { 67 | _assetsManager = new AssetsManager(); 68 | _assetsManager.addEventListener 69 | ( Event.COMPLETE 70 | , function (event:Event):void 71 | { 72 | var assetsManager:AssetsManager 73 | dispatchEvent(new Event(Event.COMPLETE)); 74 | } 75 | ); 76 | 77 | _assetsManager.addConfigurationAssets(_configuration); 78 | _assetsManager.load(); 79 | } 80 | else 81 | { 82 | dispatchEvent(new Event(Event.COMPLETE)); 83 | } 84 | } 85 | 86 | public function get configuration():XML 87 | { 88 | return _configuration; 89 | } 90 | 91 | public function get assetsManager():AssetsManager 92 | { 93 | return _assetsManager; 94 | } 95 | 96 | private var _configuration:XML; 97 | private var _assetsManager:AssetsManager; 98 | } 99 | } -------------------------------------------------------------------------------- /src/org/osmf/player/chrome/configuration/WidgetsParser.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | **********************************************************/ 19 | 20 | package org.osmf.player.chrome.configuration 21 | { 22 | import flash.utils.getDefinitionByName; 23 | 24 | import org.osmf.player.chrome.assets.AssetsManager; 25 | import org.osmf.player.chrome.widgets.*; 26 | 27 | public class WidgetsParser 28 | { 29 | public function addType(id:String, type:Class):void 30 | { 31 | widgetTypes[id.toLowerCase()] = type; 32 | } 33 | 34 | public function get widgets():Vector. 35 | { 36 | return _widgets; 37 | } 38 | 39 | public function registerWidgetType(type:String, definition:Class):void 40 | { 41 | widgetTypes[type] = definition; 42 | } 43 | 44 | public function parse(widgetsList:XMLList, assetsManager:AssetsManager, parentWidget:Widget = null):void 45 | { 46 | if (parentWidget == null) 47 | { 48 | _siblings = new Vector.(); 49 | _widgets = new Vector.(); 50 | } 51 | 52 | for each (var widgetXML:XML in widgetsList) 53 | { 54 | var widget:Widget = constructWidget(widgetXML, assetsManager); 55 | if (parentWidget != null) 56 | { 57 | _siblings.push(widget); 58 | parentWidget.addChildWidget(widget); 59 | } 60 | else 61 | { 62 | _widgets.push(widget); 63 | } 64 | } 65 | } 66 | 67 | public function getWidget(id:String):Widget 68 | { 69 | var result:Widget; 70 | 71 | if (id != null) 72 | { 73 | var lowerCaseId:String = id.toLocaleLowerCase(); 74 | var widget:Widget; 75 | 76 | if (_widgets != null) 77 | { 78 | for each (widget in _widgets) 79 | { 80 | if (widget.id && widget.id.toLocaleLowerCase() == lowerCaseId) 81 | { 82 | result = widget; 83 | break; 84 | } 85 | } 86 | } 87 | 88 | if (result == null && _siblings != null) 89 | { 90 | for each (widget in _siblings) 91 | { 92 | if (widget.id && widget.id.toLocaleLowerCase() == lowerCaseId) 93 | { 94 | result = widget; 95 | break; 96 | } 97 | } 98 | } 99 | } 100 | 101 | return result; 102 | } 103 | 104 | // Internals 105 | // 106 | 107 | private static const widgetTypes:Object 108 | = { alert: AlertDialog 109 | , button: ButtonWidget 110 | , qualityindicator: QualityIndicator 111 | , playbutton: PlayButton 112 | , pausebutton: PauseButton 113 | , mutebutton: MuteButton 114 | , scrubbar: ScrubBar 115 | , fullscreenenterbutton: FullScreenEnterButton 116 | , fullscreenleavebutton: FullScreenLeaveButton 117 | , autohidewidget: AutoHideWidget 118 | , authenticationdialog: AuthenticationDialog 119 | , label: LabelWidget 120 | , playlistpreviousbutton: PlaylistPreviousButton 121 | , playlistnextbutton: PlaylistNextButton 122 | }; 123 | 124 | private var _widgets:Vector.; 125 | private var _siblings:Vector.; 126 | 127 | private function constructWidget(xml:XML, assetsManager:AssetsManager):Widget 128 | { 129 | var typeString:String = String(xml.@type == undefined ? "" : xml.@type).toLowerCase(); 130 | var type:Class = widgetTypes[typeString] 131 | if (type == null) 132 | { 133 | try 134 | { 135 | type = flash.utils.getDefinitionByName(xml.@type || "") as Class; 136 | } 137 | catch(error:Error) 138 | { 139 | if (xml.@type != undefined) 140 | { 141 | trace("WARNING: type not found", xml.@type); 142 | } 143 | type = Widget; 144 | } 145 | } 146 | var widget:Widget = new type(); 147 | 148 | // Parse child widgets: 149 | parse(xml.widget, assetsManager, widget); 150 | 151 | // Configure widget: 152 | widget.configure(xml, assetsManager); 153 | 154 | return widget; 155 | } 156 | } 157 | } -------------------------------------------------------------------------------- /src/org/osmf/player/chrome/events/ScrubberEvent.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | **********************************************************/ 19 | 20 | package org.osmf.player.chrome.events 21 | { 22 | import flash.events.Event; 23 | 24 | public class ScrubberEvent extends Event 25 | { 26 | public static const SCRUB_START:String = "scrubStart"; 27 | public static const SCRUB_UPDATE:String = "scrubUpdate"; 28 | public static const SCRUB_END:String = "scrubEnd"; 29 | 30 | public function ScrubberEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false) 31 | { 32 | super(type, bubbles, cancelable); 33 | } 34 | 35 | } 36 | } -------------------------------------------------------------------------------- /src/org/osmf/player/chrome/events/WidgetEvent.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | **********************************************************/ 19 | 20 | package org.osmf.player.chrome.events 21 | { 22 | import flash.events.Event; 23 | 24 | public class WidgetEvent extends Event 25 | { 26 | public static const REQUEST_FULL_SCREEN:String = "requestFullScreen"; 27 | public static const REQUEST_FULL_SCREEN_FORCE_FIT:String = "requestFullScreenForceFit"; 28 | public static const VIDEO_INFO_OVERLAY_CLOSE:String = "videoInfoOverlayClose"; 29 | 30 | public function WidgetEvent(type:String, bubbles:Boolean=true, cancelable:Boolean=false) 31 | { 32 | super(type, bubbles, cancelable); 33 | } 34 | 35 | override public function clone():Event 36 | { 37 | return new WidgetEvent(type, bubbles, cancelable); 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /src/org/osmf/player/chrome/metadata/ChromeMetadata.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | **********************************************************/ 19 | 20 | package org.osmf.player.chrome.metadata 21 | { 22 | import org.osmf.metadata.Metadata; 23 | 24 | public class ChromeMetadata 25 | { 26 | public static const CHROME_METADATA_KEY:String = "http://www.osmf.org.chrome/1.0" 27 | 28 | public static const AUTO_HIDE:String = "autoHide"; 29 | public static const AUTO_HIDE_TIMEOUT:String = "autoHideTimeout"; 30 | public static const FULLSCREEN_BUTTON_STATE:String = "fullScreen"; 31 | public static const LIVE:String = "live"; 32 | } 33 | } -------------------------------------------------------------------------------- /src/org/osmf/player/chrome/utils/FormatUtils.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | **********************************************************/ 19 | 20 | package org.osmf.player.chrome.utils 21 | { 22 | /** 23 | * Formatting utilities. 24 | */ 25 | public class FormatUtils 26 | { 27 | public function FormatUtils() 28 | { 29 | } 30 | 31 | /** 32 | * Formats a string suitable for displaying the current position of the playhead and the total duration of a media. 33 | * 34 | * There are special formating rules for the currentPosition that depends on the total duration, that's why we format both values at the same time. 35 | */ 36 | public static function formatTimeStatus(currentPosition:Number, totalDuration:Number, isLive:Boolean=false, LIVE:String="Live"):Vector. 37 | { 38 | var h:Number; 39 | var m:Number; 40 | var s:Number; 41 | function prettyPrintSeconds(seconds:Number, leadingMinutes:Boolean = false, leadingHours:Boolean = false):String 42 | { 43 | seconds = Math.floor(isNaN(seconds) ? 0.0 : Math.max(0.0, seconds)); 44 | h = Math.floor(seconds / 3600.0); 45 | m = Math.floor(seconds % 3600.0 / 60.0); 46 | s = seconds % 60.0; 47 | return ((h > 0.0 || leadingHours) ? (h + ":") : "") 48 | + (((h > 0.0 || leadingMinutes) && m < 10.0) ? "0" : "") 49 | + m + ":" 50 | + (s < 10.0 ? "0" : "") 51 | + s; 52 | } 53 | 54 | var totalDurationString:String = isNaN(totalDuration) ? LIVE : prettyPrintSeconds(totalDuration); 55 | var currentPositionString:String = isLive ? LIVE : prettyPrintSeconds(currentPosition, h>0||m>9, h>0); 56 | 57 | while (currentPositionString.length < totalDurationString.length) 58 | { 59 | currentPositionString = ' ' + currentPositionString; 60 | } 61 | while (totalDurationString.length < currentPositionString.length) 62 | { 63 | totalDurationString = ' ' + totalDurationString; 64 | } 65 | 66 | var result:Vector. = new Vector.(); 67 | result[0] = currentPositionString; 68 | result[1] = totalDurationString; 69 | return result; 70 | } 71 | 72 | 73 | } 74 | } -------------------------------------------------------------------------------- /src/org/osmf/player/chrome/utils/MediaElementUtils.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | **********************************************************/ 19 | 20 | package org.osmf.player.chrome.utils 21 | { 22 | import flash.net.URLRequest; 23 | import flash.net.URLStream; 24 | 25 | import org.osmf.elements.ProxyElement; 26 | import org.osmf.media.MediaElement; 27 | import org.osmf.media.MediaResourceBase; 28 | import org.osmf.media.URLResource; 29 | import org.osmf.net.DynamicStreamingResource; 30 | import org.osmf.net.StreamingURLResource; 31 | import org.osmf.player.metadata.ResourceMetadata; 32 | 33 | /** 34 | * MediaElement utility functions 35 | */ 36 | public class MediaElementUtils 37 | { 38 | /** 39 | * Returns the top MediaElement by traversing the proxiedElement parent chain. 40 | */ 41 | public static function getMediaElementParentOfType(media:MediaElement, type:Class):MediaElement 42 | { 43 | if (media is type) 44 | { 45 | return media; 46 | } 47 | else if (media.hasOwnProperty("proxiedElement") && (media["proxiedElement"] != null)) 48 | { 49 | // WORARROUND: Use duck-typing since we need to check both 50 | // ProxyElement and ProxyElementEx which expose proxiedElement property. 51 | return getMediaElementParentOfType(media["proxiedElement"], type); 52 | } 53 | return null; 54 | } 55 | 56 | /** 57 | * Returns the highest level Resource of a Specific type by traversing the proxiedElement parent chain. 58 | */ 59 | public static function getResourceFromParentOfType(media:MediaElement, type:Class):MediaResourceBase 60 | { 61 | // If the current element is a proxy element, go up 62 | var result:MediaResourceBase = null; 63 | if (media.hasOwnProperty("proxiedElement") && (media["proxiedElement"] != null)) 64 | { 65 | result = getResourceFromParentOfType(media["proxiedElement"], type); 66 | } 67 | 68 | // If we didn't get any result from a higher level proxy 69 | // and the current media is of the needed type, return it. 70 | if (result == null && media.resource is type) 71 | { 72 | result = media.resource; 73 | } 74 | 75 | return result; 76 | } 77 | 78 | public static function getStreamType(media:MediaElement):String 79 | { 80 | if (media == null) 81 | { 82 | return null; 83 | } 84 | 85 | var streamingURLResource:StreamingURLResource = getResourceFromParentOfType(media, StreamingURLResource) as StreamingURLResource; 86 | if (streamingURLResource != null) 87 | { 88 | return streamingURLResource.streamType; 89 | } 90 | return null; 91 | } 92 | 93 | /** 94 | * Collects the metadata from the proxy chain. 95 | * Resource fields that are found higher in the proxy chain overwrite the ones 96 | * found lower. 97 | */ 98 | public static function collectResourceMetadata(mediaElement:MediaElement, resourceMetadata:ResourceMetadata):void 99 | { 100 | if (mediaElement == null) 101 | { 102 | return; 103 | } 104 | 105 | var resource:MediaResourceBase = mediaElement.resource; 106 | if (resource is URLResource) 107 | { 108 | resourceMetadata.url = (resource as URLResource).url; 109 | } 110 | 111 | if (resource is StreamingURLResource) 112 | { 113 | resourceMetadata.streamType = (resource as StreamingURLResource).streamType; 114 | } 115 | 116 | if (resource is DynamicStreamingResource) 117 | { 118 | resourceMetadata.host = (resource as DynamicStreamingResource).host; 119 | resourceMetadata.streamItems = (resource as DynamicStreamingResource).streamItems; 120 | resourceMetadata.initialIndex = (resource as DynamicStreamingResource).initialIndex; 121 | } 122 | 123 | if (mediaElement is ProxyElement) 124 | { 125 | collectResourceMetadata((mediaElement as ProxyElement).proxiedElement, resourceMetadata); 126 | } 127 | } 128 | } 129 | } -------------------------------------------------------------------------------- /src/org/osmf/player/chrome/widgets/AlertDialog.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | **********************************************************/ 19 | 20 | package org.osmf.player.chrome.widgets 21 | { 22 | import __AS3__.vec.Vector; 23 | 24 | import flash.events.MouseEvent; 25 | 26 | import org.osmf.player.chrome.assets.AssetsManager; 27 | 28 | public class AlertDialog extends Widget 29 | { 30 | // Overrides 31 | // 32 | 33 | public function AlertDialog() 34 | { 35 | super(); 36 | } 37 | 38 | override public function configure(xml:XML, assetManager:AssetsManager):void 39 | { 40 | queue = new Vector.; 41 | update(); 42 | 43 | super.configure(xml, assetManager); 44 | 45 | closeButton = getChildWidget("closeButton") as ButtonWidget; 46 | closeButton.addEventListener(MouseEvent.CLICK,onCloseButtonClick); 47 | 48 | captionLabel = getChildWidget("captionLabel") as LabelWidget; 49 | messageLabel = getChildWidget("messageLabel") as LabelWidget; 50 | } 51 | 52 | public function alert(caption:String, message:String):void 53 | { 54 | var alert:Object = {caption: caption, message:message}; 55 | if (currentAlert != null) 56 | { 57 | queue.unshift(alert); 58 | } 59 | else 60 | { 61 | currentAlert = alert; 62 | } 63 | 64 | update(); 65 | } 66 | 67 | public function close(all:Boolean=true):void 68 | { 69 | if (all) 70 | { 71 | queue = new Vector.; 72 | } 73 | onCloseButtonClick(); 74 | } 75 | 76 | // Internals 77 | // 78 | 79 | private var closeButton:ButtonWidget; 80 | private var captionLabel:LabelWidget; 81 | private var messageLabel:LabelWidget; 82 | 83 | private var queue:Vector.; 84 | private var currentAlert:Object; 85 | 86 | private function onCloseButtonClick(event:MouseEvent=null):void 87 | { 88 | currentAlert = queue.length ? queue.pop() : null; 89 | 90 | update(); 91 | } 92 | 93 | private function update():void 94 | { 95 | if (currentAlert == null) 96 | { 97 | visible = false; 98 | } 99 | else 100 | { 101 | captionLabel.text = currentAlert.caption; 102 | messageLabel.text = currentAlert.message; 103 | 104 | visible = true; 105 | } 106 | } 107 | } 108 | } -------------------------------------------------------------------------------- /src/org/osmf/player/chrome/widgets/BackButton.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | **********************************************************/ 19 | 20 | package org.osmf.player.chrome.widgets 21 | { 22 | import flash.display.StageDisplayState; 23 | import flash.events.Event; 24 | import flash.events.MouseEvent; 25 | 26 | import org.osmf.player.chrome.assets.AssetIDs; 27 | 28 | public class BackButton extends ButtonWidget 29 | { 30 | public function BackButton() 31 | { 32 | super(); 33 | 34 | upFace = AssetIDs.BACK_BUTTON_NORMAL 35 | downFace = AssetIDs.BACK_BUTTON_DOWN; 36 | overFace = AssetIDs.BACK_BUTTON_OVER; 37 | } 38 | 39 | // Overrides 40 | // 41 | 42 | override protected function onMouseClick(event:MouseEvent):void 43 | { 44 | stage.displayState = StageDisplayState.NORMAL; 45 | event.stopImmediatePropagation(); 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /src/org/osmf/player/chrome/widgets/ButtonHighlight.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | **********************************************************/ 19 | 20 | package org.osmf.player.chrome.widgets 21 | { 22 | import flash.display.DisplayObject; 23 | import flash.display.Sprite; 24 | import flash.events.MouseEvent; 25 | 26 | import org.osmf.player.chrome.assets.AssetIDs; 27 | import org.osmf.player.chrome.assets.AssetsManager; 28 | 29 | public class ButtonHighlight extends Sprite 30 | { 31 | public function ButtonHighlight(assetManager:AssetsManager) 32 | { 33 | super(); 34 | var highlight:DisplayObject = assetManager.getDisplayObject(AssetIDs.BUTTON_HIGHLIGHT); 35 | if(highlight) addChild(highlight); 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /src/org/osmf/player/chrome/widgets/ButtonWidget.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | **********************************************************/ 19 | 20 | package org.osmf.player.chrome.widgets 21 | { 22 | import flash.display.DisplayObject; 23 | import flash.events.MouseEvent; 24 | import flash.ui.Mouse; 25 | 26 | import org.osmf.player.chrome.assets.AssetsManager; 27 | 28 | public class ButtonWidget extends Widget 29 | { 30 | public function ButtonWidget() 31 | { 32 | 33 | mouseEnabled = true; 34 | 35 | addEventListener(MouseEvent.MOUSE_OVER, onMouseOver); 36 | addEventListener(MouseEvent.MOUSE_OUT, onMouseOut); 37 | addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown); 38 | addEventListener(MouseEvent.CLICK, onMouseClick_internal); 39 | } 40 | 41 | // Overrides 42 | // 43 | 44 | override public function configure(xml:XML, assetManager:AssetsManager):void 45 | { 46 | 47 | super.configure(xml, assetManager); 48 | 49 | up = assetManager.getDisplayObject(upFace); 50 | down = assetManager.getDisplayObject(downFace); 51 | over = assetManager.getDisplayObject(overFace); 52 | disabled = assetManager.getDisplayObject(disabledFace); 53 | 54 | setFace(up); 55 | } 56 | 57 | protected function onMouseOut(event:MouseEvent):void 58 | { 59 | Mouse.cursor = flash.ui.MouseCursor.ARROW; 60 | mouseOver = false; 61 | setFace(enabled ? up : disabled); 62 | } 63 | 64 | protected function onMouseOver(event:MouseEvent):void 65 | { 66 | Mouse.cursor = flash.ui.MouseCursor.BUTTON; 67 | mouseOver = true; 68 | setFace(enabled ? over : disabled); 69 | } 70 | 71 | // Internals 72 | // 73 | 74 | protected function onMouseDown(event:MouseEvent):void 75 | { 76 | mouseOver = false; 77 | setFace(enabled ? down : disabled); 78 | } 79 | 80 | private function onMouseClick_internal(event:MouseEvent):void 81 | { 82 | if (enabled == false) 83 | { 84 | event.stopImmediatePropagation(); 85 | } 86 | else 87 | { 88 | onMouseClick(event); 89 | } 90 | } 91 | 92 | // Overrides 93 | // 94 | 95 | override protected function processEnabledChange():void 96 | { 97 | setFace(enabled ? mouseOver ? over : up : disabled); 98 | 99 | super.processEnabledChange(); 100 | } 101 | 102 | protected function setFace(face:DisplayObject):void 103 | { 104 | if (currentFace != face) 105 | { 106 | if (currentFace != null) 107 | { 108 | removeChild(currentFace); 109 | } 110 | 111 | currentFace = face; 112 | 113 | if (currentFace != null) 114 | { 115 | addChildAt(currentFace, 0); 116 | 117 | width = currentFace.width; 118 | height = currentFace.height; 119 | } 120 | } 121 | } 122 | 123 | // Stubs 124 | // 125 | 126 | protected function onMouseClick(event:MouseEvent):void 127 | { 128 | } 129 | 130 | public var upFace:String = "buttonUp"; 131 | public var downFace:String = "buttonDown"; 132 | public var overFace:String = "buttonOver"; 133 | public var disabledFace:String = "buttonDisabled"; 134 | 135 | protected var currentFace:DisplayObject; 136 | protected var mouseOver:Boolean; 137 | 138 | protected var up:DisplayObject; 139 | protected var down:DisplayObject; 140 | protected var over:DisplayObject; 141 | protected var disabled:DisplayObject; 142 | } 143 | } -------------------------------------------------------------------------------- /src/org/osmf/player/chrome/widgets/FullScreenEnterButton.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | **********************************************************/ 19 | 20 | package org.osmf.player.chrome.widgets 21 | { 22 | import flash.display.StageDisplayState; 23 | import flash.events.Event; 24 | import flash.events.FullScreenEvent; 25 | import flash.events.MouseEvent; 26 | 27 | import org.osmf.containers.MediaContainer; 28 | import org.osmf.media.MediaElement; 29 | import org.osmf.player.chrome.assets.AssetIDs; 30 | import org.osmf.player.chrome.events.WidgetEvent; 31 | import org.osmf.traits.MediaTraitType; 32 | 33 | public class FullScreenEnterButton extends ButtonWidget 34 | { 35 | public var twoStepFullScreen:Boolean = false; 36 | 37 | public function FullScreenEnterButton() 38 | { 39 | addEventListener(Event.ADDED_TO_STAGE, onAddedToStage); 40 | 41 | upFace = AssetIDs.FULL_SCREEN_ENTER_NORMAL; 42 | downFace = AssetIDs.FULL_SCREEN_ENTER_DOWN; 43 | overFace = AssetIDs.FULL_SCREEN_ENTER_OVER; 44 | } 45 | 46 | // Overrides 47 | // 48 | 49 | override protected function get requiredTraits():Vector. 50 | { 51 | return _requiredTraits; 52 | } 53 | 54 | override protected function processRequiredTraitsUnavailable(element:MediaElement):void 55 | { 56 | visible = false; 57 | } 58 | 59 | override protected function processRequiredTraitsAvailable(element:MediaElement):void 60 | { 61 | visible = 62 | element != null && 63 | ( 64 | ( 65 | stage != null && stage.displayState == StageDisplayState.NORMAL || 66 | ( 67 | twoStepFullScreen ? 68 | fullScreenState != WidgetEvent.REQUEST_FULL_SCREEN_FORCE_FIT : 69 | false 70 | ) 71 | ) 72 | || 73 | stage == null 74 | ); 75 | } 76 | 77 | override protected function onMouseClick(event:MouseEvent):void 78 | { 79 | if (twoStepFullScreen) { 80 | dispatchEvent(new WidgetEvent(WidgetEvent.REQUEST_FULL_SCREEN_FORCE_FIT)); 81 | } 82 | else { 83 | dispatchEvent(new WidgetEvent(WidgetEvent.REQUEST_FULL_SCREEN)); 84 | } 85 | event.stopImmediatePropagation(); 86 | } 87 | 88 | // Internals 89 | // 90 | 91 | private function onAddedToStage(event:Event):void 92 | { 93 | stage.addEventListener(FullScreenEvent.FULL_SCREEN, onFullScreenEvent); 94 | this.root.addEventListener(WidgetEvent.REQUEST_FULL_SCREEN, onFullScreenEvent); 95 | this.root.addEventListener(WidgetEvent.REQUEST_FULL_SCREEN_FORCE_FIT, onFullScreenEvent); 96 | processRequiredTraitsAvailable(media); 97 | } 98 | 99 | private function onFullScreenEvent(event:Event):void 100 | { 101 | fullScreenState = event.type; 102 | processRequiredTraitsAvailable(media); 103 | } 104 | 105 | private var fullScreenState:String = ""; 106 | 107 | /* static */ 108 | private static const _requiredTraits:Vector. = new Vector.; 109 | _requiredTraits[0] = MediaTraitType.DISPLAY_OBJECT; 110 | } 111 | } -------------------------------------------------------------------------------- /src/org/osmf/player/chrome/widgets/FullScreenLeaveButton.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | **********************************************************/ 19 | 20 | package org.osmf.player.chrome.widgets 21 | { 22 | import flash.display.StageDisplayState; 23 | import flash.events.Event; 24 | import flash.events.FullScreenEvent; 25 | import flash.events.MouseEvent; 26 | 27 | import org.osmf.containers.MediaContainer; 28 | import org.osmf.media.MediaElement; 29 | import org.osmf.player.chrome.assets.AssetIDs; 30 | import org.osmf.player.chrome.events.WidgetEvent; 31 | import org.osmf.traits.MediaTraitType; 32 | 33 | public class FullScreenLeaveButton extends ButtonWidget 34 | { 35 | public var twoStepFullScreen:Boolean = false; 36 | 37 | public function FullScreenLeaveButton() 38 | { 39 | addEventListener(Event.ADDED_TO_STAGE, onAddedToStage); 40 | 41 | upFace = AssetIDs.FULL_SCREEN_LEAVE_NORMAL; 42 | downFace = AssetIDs.FULL_SCREEN_LEAVE_DOWN; 43 | overFace = AssetIDs.FULL_SCREEN_LEAVE_OVER; 44 | } 45 | 46 | // Overrides 47 | // 48 | 49 | override protected function get requiredTraits():Vector. 50 | { 51 | return _requiredTraits; 52 | } 53 | 54 | override protected function processRequiredTraitsUnavailable(element:MediaElement):void 55 | { 56 | visible = false; 57 | } 58 | 59 | override protected function processRequiredTraitsAvailable(element:MediaElement):void 60 | { 61 | visible = 62 | element != null && 63 | stage != null && 64 | stage.displayState != StageDisplayState.NORMAL && 65 | ( 66 | twoStepFullScreen ? 67 | fullScreenState == WidgetEvent.REQUEST_FULL_SCREEN_FORCE_FIT : 68 | true 69 | ); 70 | } 71 | 72 | override protected function onMouseClick(event:MouseEvent):void 73 | { 74 | if (twoStepFullScreen) { 75 | dispatchEvent(new WidgetEvent(WidgetEvent.REQUEST_FULL_SCREEN)); 76 | } 77 | else { 78 | stage.displayState = StageDisplayState.NORMAL; 79 | } 80 | event.stopImmediatePropagation(); 81 | } 82 | 83 | // Internals 84 | // 85 | 86 | private function onAddedToStage(event:Event):void 87 | { 88 | stage.addEventListener(FullScreenEvent.FULL_SCREEN, onFullScreenEvent); 89 | this.root.addEventListener(WidgetEvent.REQUEST_FULL_SCREEN, onFullScreenEvent); 90 | this.root.addEventListener(WidgetEvent.REQUEST_FULL_SCREEN_FORCE_FIT, onFullScreenEvent); 91 | processRequiredTraitsAvailable(media); 92 | } 93 | 94 | private function onFullScreenEvent(event:Event):void 95 | { 96 | fullScreenState = event.type; 97 | processRequiredTraitsAvailable(media); 98 | } 99 | 100 | private var fullScreenState:String = ""; 101 | 102 | /* static */ 103 | private static const _requiredTraits:Vector. = new Vector.; 104 | _requiredTraits[0] = MediaTraitType.DISPLAY_OBJECT; 105 | } 106 | } -------------------------------------------------------------------------------- /src/org/osmf/player/chrome/widgets/PauseButton.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | **********************************************************/ 19 | 20 | package org.osmf.player.chrome.widgets 21 | { 22 | import flash.events.Event; 23 | import flash.events.MouseEvent; 24 | 25 | import org.osmf.player.chrome.assets.AssetIDs; 26 | import org.osmf.traits.MediaTraitType; 27 | import org.osmf.traits.PlayState; 28 | import org.osmf.traits.PlayTrait; 29 | 30 | public class PauseButton extends PlayableButton 31 | { 32 | 33 | public function PauseButton() 34 | { 35 | super(); 36 | 37 | upFace = AssetIDs.PAUSE_BUTTON_NORMAL; 38 | downFace = AssetIDs.PAUSE_BUTTON_DOWN; 39 | overFace = AssetIDs.PAUSE_BUTTON_OVER; 40 | } 41 | // Overrides 42 | // 43 | 44 | 45 | override protected function onMouseClick(event:MouseEvent):void 46 | { 47 | var playable:PlayTrait = media.getTrait(MediaTraitType.PLAY) as PlayTrait; 48 | if ( playable.canPause) 49 | { 50 | playable.pause(); 51 | } 52 | else 53 | { 54 | playable.stop(); 55 | } 56 | event.stopImmediatePropagation(); 57 | } 58 | 59 | override protected function visibilityDeterminingEventHandler(event:Event = null):void 60 | { 61 | visible = (playable && playable.playState == PlayState.PLAYING) 62 | if (media && media.metadata) 63 | { 64 | visible ||= media.metadata.getValue("Advertisement") != null; 65 | } 66 | } 67 | } 68 | } -------------------------------------------------------------------------------- /src/org/osmf/player/chrome/widgets/PlayButton.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | **********************************************************/ 19 | 20 | package org.osmf.player.chrome.widgets 21 | { 22 | import flash.events.Event; 23 | import flash.events.MouseEvent; 24 | 25 | import org.osmf.player.chrome.assets.AssetIDs; 26 | import org.osmf.traits.MediaTraitType; 27 | import org.osmf.traits.PlayState; 28 | import org.osmf.traits.PlayTrait; 29 | 30 | public class PlayButton extends PlayableButton 31 | { 32 | public function PlayButton() 33 | { 34 | super(); 35 | 36 | upFace = AssetIDs.PLAY_BUTTON_NORMAL 37 | downFace = AssetIDs.PLAY_BUTTON_DOWN; 38 | overFace = AssetIDs.PLAY_BUTTON_OVER; 39 | } 40 | 41 | // Overrides 42 | // 43 | 44 | override protected function onMouseClick(event:MouseEvent):void 45 | { 46 | var playable:PlayTrait = media.getTrait(MediaTraitType.PLAY) as PlayTrait; 47 | playable.play(); 48 | event.stopImmediatePropagation(); 49 | } 50 | 51 | override protected function visibilityDeterminingEventHandler(event:Event = null):void 52 | { 53 | visible = playable && playable.playState != PlayState.PLAYING; 54 | 55 | if (media && media.metadata) 56 | { 57 | visible &&= media.metadata.getValue("Advertisement") == null; 58 | } 59 | } 60 | } 61 | } -------------------------------------------------------------------------------- /src/org/osmf/player/chrome/widgets/PlayButtonOverlay.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | **********************************************************/ 19 | 20 | package org.osmf.player.chrome.widgets 21 | { 22 | import flash.events.Event; 23 | import flash.events.MouseEvent; 24 | import flash.events.TimerEvent; 25 | import flash.utils.Timer; 26 | 27 | import org.osmf.player.chrome.assets.AssetIDs; 28 | import org.osmf.player.chrome.assets.AssetsManager; 29 | import org.osmf.traits.MediaTraitType; 30 | import org.osmf.traits.PlayState; 31 | import org.osmf.traits.PlayTrait; 32 | import org.osmf.traits.SeekTrait; 33 | import org.osmf.traits.TimeTrait; 34 | 35 | public class PlayButtonOverlay extends PlayableButton 36 | { 37 | // Public API 38 | // 39 | 40 | public function PlayButtonOverlay() 41 | { 42 | visibilityTimer = new Timer(VISIBILITY_DELAY, 1); 43 | visibilityTimer.addEventListener(TimerEvent.TIMER_COMPLETE, onVisibilityTimerComplete); 44 | 45 | super(); 46 | 47 | upFace = AssetIDs.PLAY_BUTTON_OVERLAY_NORMAL; 48 | downFace = AssetIDs.PLAY_BUTTON_OVERLAY_DOWN; 49 | overFace = AssetIDs.PLAY_BUTTON_OVERLAY_OVER; 50 | } 51 | 52 | // Overrides 53 | // 54 | 55 | override public function configure(xml:XML, assetManager:AssetsManager):void 56 | { 57 | super.configure(xml, assetManager); 58 | 59 | // Make sure that the overlay is toggle invisible intially: 60 | visible = false; 61 | } 62 | 63 | override public function set visible(value:Boolean):void 64 | { 65 | if (value != _visible) 66 | { 67 | _visible = value; 68 | 69 | if (value == false) 70 | { 71 | visibilityTimer.stop(); 72 | super.visible = false; 73 | } 74 | else 75 | { 76 | if (visibilityTimer.running) 77 | { 78 | visibilityTimer.stop(); 79 | } 80 | if (parent) 81 | { 82 | visibilityTimer.reset(); 83 | visibilityTimer.start(); 84 | } 85 | else 86 | { 87 | super.visible = true; 88 | } 89 | } 90 | } 91 | } 92 | 93 | override public function get visible():Boolean 94 | { 95 | return _visible; 96 | } 97 | 98 | override protected function onMouseClick(event:MouseEvent):void 99 | { 100 | var playable:PlayTrait = media.getTrait(MediaTraitType.PLAY) as PlayTrait; 101 | playable.play(); 102 | } 103 | 104 | override protected function visibilityDeterminingEventHandler(event:Event = null):void 105 | { 106 | var newVisibleValue:Boolean = playable && playable.playState == PlayState.STOPPED; 107 | if (newVisibleValue) 108 | { 109 | // Only show the play button overlay when we're at the beginning 110 | // of the content, or at the end of the content: 111 | var time:TimeTrait = media.getTrait(MediaTraitType.TIME) as TimeTrait; 112 | if (time) 113 | { 114 | newVisibleValue 115 | = time.currentTime == 0 116 | || Math.abs(time.currentTime - time.duration) < 2; 117 | } 118 | } 119 | 120 | visible = newVisibleValue; 121 | } 122 | 123 | // Internals 124 | // 125 | 126 | private function onVisibilityTimerComplete(event:TimerEvent):void 127 | { 128 | super.visible = true; 129 | } 130 | 131 | private var _visible:Boolean = true; 132 | private var visibilityTimer:Timer; 133 | 134 | /* static */ 135 | private static const VISIBILITY_DELAY:int = 500; 136 | } 137 | } -------------------------------------------------------------------------------- /src/org/osmf/player/chrome/widgets/PlayableButton.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | **********************************************************/ 19 | 20 | package org.osmf.player.chrome.widgets 21 | { 22 | import flash.events.Event; 23 | 24 | import org.osmf.events.MediaElementEvent; 25 | import org.osmf.events.PlayEvent; 26 | import org.osmf.media.MediaElement; 27 | import org.osmf.traits.MediaTraitType; 28 | import org.osmf.traits.PlayTrait; 29 | 30 | public class PlayableButton extends ButtonWidget 31 | { 32 | // Protected 33 | // 34 | 35 | protected function get playable():PlayTrait 36 | { 37 | return _playable; 38 | } 39 | 40 | // Overrides 41 | // 42 | 43 | override protected function get requiredTraits():Vector. 44 | { 45 | return _requiredTraits; 46 | } 47 | 48 | override protected function processMediaElementChange(oldMediaElement:MediaElement):void 49 | { 50 | setPlayable(media ? media.getTrait(MediaTraitType.PLAY) as PlayTrait : null); 51 | } 52 | 53 | override protected function onMediaElementTraitAdd(event:MediaElementEvent):void 54 | { 55 | if (event.traitType == MediaTraitType.PLAY) 56 | { 57 | setPlayable(media.getTrait(MediaTraitType.PLAY) as PlayTrait); 58 | } 59 | 60 | super.onMediaElementTraitAdd(event); 61 | } 62 | 63 | override protected function onMediaElementTraitRemove(event:MediaElementEvent):void 64 | { 65 | if ((event.traitType == MediaTraitType.PLAY) && _playable) 66 | { 67 | setPlayable(null); 68 | } 69 | 70 | super.onMediaElementTraitRemove(event); 71 | } 72 | 73 | override protected function processRequiredTraitsAvailable(element:MediaElement):void 74 | { 75 | setPlayable(media.getTrait(MediaTraitType.PLAY) as PlayTrait); 76 | } 77 | 78 | override protected function processRequiredTraitsUnavailable(element:MediaElement):void 79 | { 80 | setPlayable(null); 81 | } 82 | 83 | // Stubs 84 | // 85 | 86 | protected function visibilityDeterminingEventHandler(event:Event = null):void 87 | { 88 | } 89 | 90 | // Internals 91 | // 92 | 93 | private var _playable:PlayTrait; 94 | 95 | /* static */ 96 | private static const _requiredTraits:Vector. = new Vector.; 97 | _requiredTraits[0] = MediaTraitType.PLAY; 98 | 99 | private function setPlayable(value:PlayTrait):void 100 | { 101 | if (value != _playable) 102 | { 103 | if (_playable != null) 104 | { 105 | _playable.removeEventListener(PlayEvent.CAN_PAUSE_CHANGE, visibilityDeterminingEventHandler); 106 | _playable.removeEventListener(PlayEvent.PLAY_STATE_CHANGE, visibilityDeterminingEventHandler); 107 | _playable = null; 108 | } 109 | 110 | _playable = value; 111 | 112 | if (_playable) 113 | { 114 | _playable.addEventListener(PlayEvent.CAN_PAUSE_CHANGE, visibilityDeterminingEventHandler); 115 | _playable.addEventListener(PlayEvent.PLAY_STATE_CHANGE, visibilityDeterminingEventHandler); 116 | } 117 | } 118 | visibilityDeterminingEventHandler(); 119 | } 120 | } 121 | } -------------------------------------------------------------------------------- /src/org/osmf/player/chrome/widgets/PlaylistNextButton.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | **********************************************************/ 19 | 20 | package org.osmf.player.chrome.widgets 21 | { 22 | import flash.events.MouseEvent; 23 | 24 | import org.osmf.events.MediaElementEvent; 25 | import org.osmf.events.MetadataEvent; 26 | import org.osmf.media.MediaElement; 27 | import org.osmf.metadata.Metadata; 28 | import org.osmf.player.chrome.assets.AssetIDs; 29 | 30 | public class PlaylistNextButton extends ButtonWidget 31 | { 32 | // Public Interface 33 | // 34 | 35 | public function PlaylistNextButton() 36 | { 37 | super(); 38 | 39 | upFace = AssetIDs.NEXT_BUTTON_NORMAL; 40 | downFace = AssetIDs.NEXT_BUTTON_DOWN; 41 | overFace = AssetIDs.NEXT_BUTTON_OVER; 42 | disabledFace = AssetIDs.NEXT_BUTTON_DISABLED; 43 | 44 | visible = false; 45 | } 46 | 47 | // Overrides 48 | // 49 | 50 | override protected function processMediaElementChange(oldMediaElement:MediaElement):void 51 | { 52 | if (oldMediaElement != null) 53 | { 54 | oldMediaElement.removeEventListener(MediaElementEvent.METADATA_ADD, onPlaylistMetadataChange); 55 | oldMediaElement.removeEventListener(MediaElementEvent.METADATA_REMOVE, onPlaylistMetadataChange); 56 | } 57 | if (media != null) 58 | { 59 | media.addEventListener(MediaElementEvent.METADATA_ADD, onPlaylistMetadataChange); 60 | media.addEventListener(MediaElementEvent.METADATA_REMOVE, onPlaylistMetadataChange); 61 | } 62 | onPlaylistMetadataChange(); 63 | } 64 | 65 | override protected function onMouseClick(event:MouseEvent):void 66 | { 67 | var playlistMetadata:Metadata 68 | = media 69 | ? media.getMetadata("http://www.osmf.org.player/1.0/playlist") 70 | : null; 71 | 72 | if (playlistMetadata) 73 | { 74 | playlistMetadata.addValue("gotoNext", true); 75 | } 76 | } 77 | 78 | // Internals 79 | // 80 | 81 | 82 | 83 | private function onPlaylistMetadataChange(event:MediaElementEvent = null):void 84 | { 85 | var playlistMetadata:Metadata 86 | = media 87 | ? media.getMetadata("http://www.osmf.org.player/1.0/playlist") 88 | : null; 89 | 90 | visible = playlistMetadata != null; 91 | if (playlistMetadata) 92 | { 93 | playlistMetadata.addEventListener 94 | ( MetadataEvent.VALUE_CHANGE 95 | , onPlaylistMetadataValueChange 96 | ); 97 | 98 | enabled = playlistMetadata.getValue("nextElement") != null; 99 | } 100 | } 101 | 102 | private function onPlaylistMetadataValueChange(event:MetadataEvent):void 103 | { 104 | var playlistMetadata:Metadata = event.target as Metadata; 105 | enabled = playlistMetadata.getValue("nextElement") != null 106 | && !playlistMetadata.getValue("switching"); 107 | } 108 | } 109 | } -------------------------------------------------------------------------------- /src/org/osmf/player/chrome/widgets/PlaylistPreviousButton.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | **********************************************************/ 19 | 20 | package org.osmf.player.chrome.widgets 21 | { 22 | import flash.events.MouseEvent; 23 | 24 | import org.osmf.player.chrome.assets.AssetIDs; 25 | import org.osmf.events.MediaElementEvent; 26 | import org.osmf.events.MetadataEvent; 27 | import org.osmf.media.MediaElement; 28 | import org.osmf.metadata.Metadata; 29 | 30 | public class PlaylistPreviousButton extends ButtonWidget 31 | { 32 | public function PlaylistPreviousButton() 33 | { 34 | super(); 35 | 36 | upFace = AssetIDs.PREVIOUS_BUTTON_NORMAL; 37 | downFace = AssetIDs.PREVIOUS_BUTTON_DOWN; 38 | overFace = AssetIDs.PREVIOUS_BUTTON_OVER; 39 | disabledFace = AssetIDs.PREVIOUS_BUTTON_DISABLED; 40 | 41 | visible = false; 42 | } 43 | 44 | // Overrides 45 | // 46 | 47 | override protected function processMediaElementChange(oldMediaElement:MediaElement):void 48 | { 49 | if (oldMediaElement != null) 50 | { 51 | oldMediaElement.removeEventListener(MediaElementEvent.METADATA_ADD, onPlaylistMetadataChange); 52 | oldMediaElement.removeEventListener(MediaElementEvent.METADATA_REMOVE, onPlaylistMetadataChange); 53 | } 54 | if (media != null) 55 | { 56 | media.addEventListener(MediaElementEvent.METADATA_ADD, onPlaylistMetadataChange); 57 | media.addEventListener(MediaElementEvent.METADATA_REMOVE, onPlaylistMetadataChange); 58 | } 59 | onPlaylistMetadataChange(); 60 | } 61 | 62 | override protected function onMouseClick(event:MouseEvent):void 63 | { 64 | var playlistMetadata:Metadata 65 | = media 66 | ? media.getMetadata(PLAYLIST_METADATA_NS) 67 | : null; 68 | 69 | if (playlistMetadata) 70 | { 71 | playlistMetadata.addValue(GOTO_PREVIOUS, true); 72 | } 73 | } 74 | 75 | // Internals 76 | // 77 | 78 | private function onPlaylistMetadataChange(event:MediaElementEvent = null):void 79 | { 80 | var playlistMetadata:Metadata 81 | = media 82 | ? media.getMetadata(PLAYLIST_METADATA_NS) 83 | : null; 84 | 85 | visible = playlistMetadata != null; 86 | if (playlistMetadata) 87 | { 88 | playlistMetadata.addEventListener 89 | ( MetadataEvent.VALUE_CHANGE 90 | , onPlaylistMetadataValueChange 91 | ); 92 | 93 | enabled = playlistMetadata.getValue(PREVIOUS_ELEMENT) != null 94 | && !playlistMetadata.getValue(SWITCHING); 95 | } 96 | } 97 | 98 | private function onPlaylistMetadataValueChange(event:MetadataEvent):void 99 | { 100 | var playlistMetadata:Metadata = event.target as Metadata; 101 | enabled = playlistMetadata.getValue(PREVIOUS_ELEMENT) != null 102 | && !playlistMetadata.getValue(SWITCHING); 103 | } 104 | 105 | /* static */ 106 | private static const PLAYLIST_METADATA_NS:String = "http://www.osmf.org.player/1.0/playlist"; 107 | private static const PREVIOUS_ELEMENT:String = "previousElement"; 108 | private static const GOTO_PREVIOUS:String = "gotoPrevious"; 109 | public static const SWITCHING:String = "switching"; 110 | } 111 | } -------------------------------------------------------------------------------- /src/org/osmf/player/chrome/widgets/TimeHintWidget.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | * 19 | **********************************************************/ 20 | 21 | package org.osmf.player.chrome.widgets 22 | { 23 | import flash.display.DisplayObject; 24 | import flash.text.TextField; 25 | import flash.text.TextFormatAlign; 26 | 27 | import org.osmf.player.chrome.assets.AssetsManager; 28 | import org.osmf.player.chrome.assets.FontAsset; 29 | 30 | public class TimeHintWidget extends LabelWidget 31 | { 32 | 33 | // Overrides 34 | // 35 | 36 | override public function set text(value:String):void 37 | { 38 | if (value != text) 39 | { 40 | super.text = value; 41 | 42 | // center the text horizontally 43 | // and vertically within the bubble area 44 | textField.width = textField.textWidth; 45 | textField.x = getChildAt(0).width/2 - textField.width/2; 46 | // get the bubble height and substract the stem and the shadow to 47 | // find the vertically available space to center in 48 | textField.y = _topPaddings + (_availableBubbleHeight - parseInt(textField.getTextFormat().size.toString())) / 2; 49 | } 50 | } 51 | 52 | // Internals 53 | // 54 | 55 | // TODO: need to make these publicly available for future skins that 56 | // need different spacing and propagate the properties in xml skin file 57 | private var _topPaddings:uint = 2; 58 | private var _availableBubbleHeight:uint = 19; 59 | } 60 | } -------------------------------------------------------------------------------- /src/org/osmf/player/chrome/widgets/TotalTimeWidget.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | * 19 | **********************************************************/ 20 | 21 | package org.osmf.player.chrome.widgets 22 | { 23 | import flash.events.Event; 24 | import flash.events.TimerEvent; 25 | import flash.geom.PerspectiveProjection; 26 | import flash.media.Microphone; 27 | import flash.text.TextFormat; 28 | import flash.text.TextFormatAlign; 29 | import flash.utils.Timer; 30 | 31 | import org.osmf.events.MediaElementEvent; 32 | import org.osmf.events.MetadataEvent; 33 | import org.osmf.events.SeekEvent; 34 | import org.osmf.events.TimeEvent; 35 | import org.osmf.layout.HorizontalAlign; 36 | import org.osmf.layout.LayoutMode; 37 | import org.osmf.layout.VerticalAlign; 38 | import org.osmf.media.MediaElement; 39 | import org.osmf.media.MediaPlayer; 40 | import org.osmf.metadata.Metadata; 41 | import org.osmf.net.StreamType; 42 | import org.osmf.player.chrome.assets.AssetsManager; 43 | import org.osmf.player.chrome.metadata.ChromeMetadata; 44 | import org.osmf.player.chrome.utils.FormatUtils; 45 | import org.osmf.player.media.StrobeMediaPlayer; 46 | import org.osmf.player.metadata.MediaMetadata; 47 | import org.osmf.traits.MediaTraitType; 48 | import org.osmf.traits.SeekTrait; 49 | import org.osmf.traits.TimeTrait; 50 | 51 | /** 52 | * CurrentTimeWidget displays the current time and the total duration of the media. 53 | * 54 | */ 55 | public class TotalTimeWidget extends TimeLabelWidget 56 | { 57 | // Overrides 58 | // 59 | 60 | /** 61 | * Updates the displayed text using the time values provided as arguments. 62 | */ 63 | override internal function updateValues(currentTimePosition:Number, totalDuration:Number, isLive:Boolean):void 64 | { 65 | // WORKARROUND: ST-285 CLONE -Multicast live duration 66 | // Check is the value is over the int range, and turn it into a NaN 67 | if (totalDuration > int.MAX_VALUE || (mediaPlayer != null && mediaPlayer.streamType == StreamType.LIVE)) 68 | { 69 | totalDuration = NaN; 70 | } 71 | 72 | // Don't display the time labels if total duration is 0 73 | if (isNaN(totalDuration) || totalDuration == 0) 74 | { 75 | if (currentTimePosition > 0 || isLive) 76 | { 77 | timeLabel.visible = false; 78 | } 79 | } 80 | else 81 | { 82 | timeLabel.visible = true; 83 | 84 | var newValues:Vector. = FormatUtils.formatTimeStatus(currentTimePosition, totalDuration, isLive, LIVE); 85 | 86 | // WORKARROUND: adding additional spaces since I'm unable to position the text nicely 87 | var totalTimeString:String = " " + newValues[1] + " "; 88 | 89 | var measuredWidth:Number = timeLabel.measuredWidth; 90 | timeLabel.text = totalTimeString; 91 | } 92 | } 93 | 94 | override public function configure(xml:XML, assetManager:AssetsManager):void 95 | { 96 | setSuperVisible(false); 97 | layoutMetadata.percentHeight = 100; 98 | layoutMetadata.layoutMode = LayoutMode.HORIZONTAL; 99 | layoutMetadata.horizontalAlign = HorizontalAlign.RIGHT; 100 | layoutMetadata.verticalAlign = VerticalAlign.MIDDLE; 101 | 102 | // Current time 103 | timeLabel = new LabelWidget(); 104 | timeLabel.autoSize = true; 105 | timeLabel.layoutMetadata.verticalAlign = VerticalAlign.MIDDLE; 106 | timeLabel.layoutMetadata.horizontalAlign = HorizontalAlign.RIGHT; 107 | addChildWidget(timeLabel); 108 | 109 | timeLabel.configure(xml, assetManager); 110 | 111 | super.configure(xml, assetManager); 112 | 113 | timeLabel.text = TIME_ZERO; 114 | measure(); 115 | } 116 | } 117 | } -------------------------------------------------------------------------------- /src/org/osmf/player/chrome/widgets/WidgetIDs.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | * 19 | **********************************************************/ 20 | 21 | package org.osmf.player.chrome.widgets 22 | { 23 | public class WidgetIDs 24 | { 25 | /* static */ 26 | 27 | public static const CONTROL_BAR:String = "controlBar"; 28 | public static const SCRUB_BAR:String = "scrubBar"; 29 | public static const MUTE_BUTTON:String = "muteButton"; 30 | public static const FULL_SCREEN_ENTER_BUTTON:String = "fullscreenEnterButton"; 31 | public static const LOGIN:String = "login"; 32 | public static const ERROR_ICON:String = "errorIcon"; 33 | public static const ERROR_LABEL:String = "errorLabel"; 34 | public static const USERNAME:String = "username"; 35 | public static const PASSWORD:String = "password"; 36 | public static const SUBMIT_BUTTON:String = "submitButton"; 37 | public static const CANCEL_BUTTON:String = "cancelButton"; 38 | public static const CLOSE_BUTTON:String = "closeButton"; 39 | public static const ALERT:String = "alert"; 40 | public static const CAPTION_LABEL:String = "captionLabel"; 41 | public static const MESSAGE_LABEL:String = "messageLabel"; 42 | public static const ERROR:String = "error"; 43 | 44 | } 45 | } -------------------------------------------------------------------------------- /src/org/osmf/player/configuration/ConfigurationLoader.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | * 19 | **********************************************************/ 20 | 21 | package org.osmf.player.configuration 22 | { 23 | import flash.events.Event; 24 | import flash.events.EventDispatcher; 25 | import flash.events.IOErrorEvent; 26 | import flash.events.SecurityErrorEvent; 27 | import flash.net.URLLoader; 28 | import flash.net.URLRequest; 29 | 30 | import org.osmf.player.chrome.configuration.ConfigurationUtils; 31 | 32 | [Event(name="complete", type="flash.events.Event")] 33 | 34 | /** 35 | * Loads a configuration model from flashvars and external configuration files. 36 | */ 37 | public class ConfigurationLoader extends EventDispatcher 38 | { 39 | public function ConfigurationLoader(configurationDeserializer:ConfigurationFlashvarsDeserializer, xmlDeserializer:ConfigurationXMLDeserializer) 40 | { 41 | this.flashvarsDeserializer = configurationDeserializer; 42 | this.xmlDeserializer = xmlDeserializer; 43 | } 44 | 45 | public function load(parameters:Object, configuration:PlayerConfiguration):void 46 | { 47 | 48 | // Parse configuration from the parameters passed on embedding 49 | // StrobeMediaPlayback.swf: 50 | if (parameters.hasOwnProperty("configuration")) 51 | { 52 | var configurationContent:String = parameters["configuration"]; 53 | // if ((configurationContent.toLowerCase().lastIndexOf(".xml") == (configurationContent.length - 4))) 54 | { 55 | var loader:XMLFileLoader = new XMLFileLoader(); 56 | loader.addEventListener(Event.COMPLETE, loadConfiguration); 57 | loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, loadConfiguration); 58 | loader.addEventListener(IOErrorEvent.IO_ERROR, loadConfiguration); 59 | function loadConfiguration(event:Event):void 60 | { 61 | loader.removeEventListener(Event.COMPLETE, loadConfiguration); 62 | loader.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, loadConfiguration); 63 | loader.removeEventListener(IOErrorEvent.IO_ERROR, loadConfiguration); 64 | 65 | if (loader.xml != null) 66 | { 67 | xmlDeserializer.deserialize(loader.xml); 68 | } 69 | flashvarsDeserializer.deserialize(parameters); 70 | 71 | dispatchEvent(new Event(Event.COMPLETE)); 72 | } 73 | loader.load(configurationContent); 74 | } 75 | // else {load content directly} 76 | } 77 | else 78 | { 79 | flashvarsDeserializer.deserialize(parameters); 80 | dispatchEvent(new Event(Event.COMPLETE)); 81 | } 82 | } 83 | 84 | // Internals 85 | // 86 | 87 | private var xmlDeserializer:ConfigurationXMLDeserializer; 88 | private var flashvarsDeserializer:ConfigurationFlashvarsDeserializer; 89 | } 90 | } -------------------------------------------------------------------------------- /src/org/osmf/player/configuration/ControlBarMode.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | * 19 | **********************************************************/ 20 | 21 | package org.osmf.player.configuration 22 | { 23 | 24 | /** 25 | * Indicates how the control bar should be positioned relative to the video. 26 | */ 27 | public final class ControlBarMode 28 | { 29 | /** 30 | * NONE - a control bar will not be displayed. 31 | * 32 | * @langversion 3.0 33 | * @playerversion Flash 10 34 | * @playerversion AIR 1.5 35 | * @productversion OSMF 1.0 36 | */ 37 | public static const NONE:String = "none"; 38 | 39 | 40 | /** 41 | * BOTTOM - the ControlBar will be displayed under the player 42 | * 43 | * @langversion 3.0 44 | * @playerversion Flash 10 45 | * @playerversion AIR 1.5 46 | * @productversion OSMF 1.0 47 | */ 48 | public static const DOCKED:String = "docked"; 49 | 50 | /** 51 | * OVER - the ControlBar will be displayed over the player 52 | * 53 | * @langversion 3.0 54 | * @playerversion Flash 10 55 | * @playerversion AIR 1.5 56 | * @productversion OSMF 1.0 57 | */ 58 | public static const FLOATING:String = "floating"; 59 | 60 | /** 61 | * values - the list of values provided by this enum. 62 | * 63 | * @langversion 3.0 64 | * @playerversion Flash 10 65 | * @playerversion AIR 1.5 66 | * @productversion OSMF 1.0 67 | */ 68 | public static const values:Array = [ControlBarMode.DOCKED, ControlBarMode.FLOATING, ControlBarMode.NONE]; 69 | } 70 | } -------------------------------------------------------------------------------- /src/org/osmf/player/configuration/ControlBarType.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | * 19 | **********************************************************/ 20 | 21 | package org.osmf.player.configuration 22 | { 23 | 24 | /** 25 | * Indicates the control bar context. 26 | */ 27 | public final class ControlBarType 28 | { 29 | /** 30 | * DESKTOP - the normal control bar will be displayed. 31 | * 32 | * @langversion 3.0 33 | * @playerversion Flash 10 34 | * @playerversion AIR 1.5 35 | * @productversion OSMF 1.0 36 | */ 37 | public static const DESKTOP:String = "desktop"; 38 | 39 | 40 | /** 41 | * TABLET - the TabletControlBar will be displayed under the player 42 | * 43 | * @langversion 3.0 44 | * @playerversion Flash 10 45 | * @playerversion AIR 1.5 46 | * @productversion OSMF 1.0 47 | */ 48 | public static const TABLET:String = "tablet"; 49 | 50 | /** 51 | * SMARTPHONE - the SmartphoneControlBar will be displayed over the player 52 | * 53 | * @langversion 3.0 54 | * @playerversion Flash 10 55 | * @playerversion AIR 1.5 56 | * @productversion OSMF 1.0 57 | */ 58 | public static const SMARTPHONE:String = "smartphone"; 59 | 60 | /** 61 | * values - the list of values provided by this enum. 62 | * 63 | * @langversion 3.0 64 | * @playerversion Flash 10 65 | * @playerversion AIR 1.5 66 | * @productversion OSMF 1.0 67 | */ 68 | public static const values:Array = [ControlBarType.SMARTPHONE, ControlBarType.TABLET, ControlBarType.DESKTOP]; 69 | } 70 | } -------------------------------------------------------------------------------- /src/org/osmf/player/configuration/SkinParser.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | * 19 | **********************************************************/ 20 | 21 | package org.osmf.player.configuration 22 | { 23 | import flash.display.Bitmap; 24 | 25 | import org.osmf.player.chrome.assets.AssetLoader; 26 | import org.osmf.player.chrome.assets.AssetsManager; 27 | import org.osmf.player.chrome.assets.BitmapResource; 28 | 29 | /** 30 | * Defines a parser for XML based player skin files. 31 | */ 32 | public class SkinParser 33 | { 34 | public function parse(value:XML, assetManager:AssetsManager):void 35 | { 36 | if (value != null) 37 | { 38 | var result:Vector. = new Vector.(); 39 | 40 | for each (var element:XML in value.element) 41 | { 42 | parseElement(element, "", assetManager); 43 | } 44 | 45 | for each (var elements:XML in value.elements) 46 | { 47 | parseElements(elements, assetManager); 48 | } 49 | } 50 | } 51 | 52 | public function parseElements(value:XML, assetManager:AssetsManager):void 53 | { 54 | var basePath:String = value.@basePath || ""; 55 | for each (var element:XML in value.element) 56 | { 57 | parseElement(element, basePath, assetManager); 58 | } 59 | } 60 | 61 | public function parseElement(value:XML, basePath:String, assetManager:AssetsManager):void 62 | { 63 | var id:String = value.@id; 64 | if (id && id != "") 65 | { 66 | assetManager.addAsset 67 | ( new BitmapResource 68 | ( id 69 | , basePath + value.@src 70 | , false 71 | , null 72 | ) 73 | , new AssetLoader() 74 | ); 75 | } 76 | else 77 | { 78 | trace("WARNING: missing skin element id (for the asset at", basePath + value.@src,")"); 79 | } 80 | } 81 | } 82 | } -------------------------------------------------------------------------------- /src/org/osmf/player/configuration/VideoRenderingMode.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | * 19 | **********************************************************/ 20 | 21 | package org.osmf.player.configuration 22 | { 23 | /** 24 | * VideoRenderingMode is an enumeration which holds the configuration options for how smoothing and deblocking should be applied. 25 | * Note that this is used together with the highQualityThreshold configuration option. 26 | */ 27 | public class VideoRenderingMode 28 | { 29 | /** 30 | * NONE - disable both smoothing and deblocking. 31 | * 32 | * @langversion 3.0 33 | * @playerversion Flash 10 34 | * @playerversion AIR 1.5 35 | * @productversion OSMF 1.0 36 | */ 37 | public static const NONE:uint = 0x0; 38 | 39 | /** 40 | * SMOOTHING - enable smoothing only. 41 | * 42 | * @langversion 3.0 43 | * @playerversion Flash 10 44 | * @playerversion AIR 1.5 45 | * @productversion OSMF 1.0 46 | */ 47 | public static const SMOOTHING:uint = 0x1; 48 | 49 | /** 50 | * DEBLOCKING - enabled deblocking only 51 | * 52 | * @langversion 3.0 53 | * @playerversion Flash 10 54 | * @playerversion AIR 1.5 55 | * @productversion OSMF 1.0 56 | */ 57 | public static const DEBLOCKING:uint = 0x2; 58 | 59 | /** 60 | * SMOOTHING_DEBLOCKING - enable both smoothing and deblocking. 61 | * 62 | * @langversion 3.0 63 | * @playerversion Flash 10 64 | * @playerversion AIR 1.5 65 | * @productversion OSMF 1.0 66 | */ 67 | public static const SMOOTHING_DEBLOCKING:uint = 0x3; 68 | 69 | /** 70 | * AUTO - the value will be determined by SD/HD rules. 71 | * 72 | * @langversion 3.0 73 | * @playerversion Flash 10 74 | * @playerversion AIR 1.5 75 | * @productversion OSMF 1.0 76 | */ 77 | public static const AUTO:uint = 0x4; 78 | 79 | /** 80 | * values - the list of values provided by this enum. 81 | * 82 | * @langversion 3.0 83 | * @playerversion Flash 10 84 | * @playerversion AIR 1.5 85 | * @productversion OSMF 1.0 86 | */ 87 | public static const values:Array = [VideoRenderingMode.NONE, VideoRenderingMode.SMOOTHING, VideoRenderingMode.DEBLOCKING, VideoRenderingMode.SMOOTHING_DEBLOCKING, VideoRenderingMode.AUTO]; 88 | } 89 | } -------------------------------------------------------------------------------- /src/org/osmf/player/configuration/XMLFileLoader.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | * 19 | **********************************************************/ 20 | 21 | package org.osmf.player.configuration 22 | { 23 | import flash.display.Loader; 24 | import flash.events.Event; 25 | import flash.events.EventDispatcher; 26 | import flash.events.IOErrorEvent; 27 | import flash.events.SecurityErrorEvent; 28 | import flash.net.URLLoader; 29 | import flash.net.URLRequest; 30 | 31 | [Event(name="complete", type="flash.events.Event")] 32 | [Event(name="io_error", type="flash.events.IOErrorEvent")] 33 | [Event(name="security_error", type="flash.events.SecurityErrorEvent")] 34 | 35 | /** 36 | * Loads an XML file. 37 | */ 38 | public class XMLFileLoader extends EventDispatcher 39 | { 40 | public function load(url:String):void 41 | { 42 | this.url = url; 43 | 44 | loader = new URLLoader(); 45 | loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, errorHandler); 46 | loader.addEventListener(IOErrorEvent.IO_ERROR, errorHandler); 47 | loader.addEventListener(Event.COMPLETE, completionSignalingHandler); 48 | loader.load(new URLRequest(url)); 49 | } 50 | 51 | public function get xml():XML 52 | { 53 | var xml:XML = null; 54 | try 55 | { 56 | xml = loader 57 | ? loader.data != null 58 | ? new XML(loader.data) 59 | : null 60 | : null; 61 | } 62 | catch (error:Error) 63 | { 64 | } 65 | return xml; 66 | } 67 | 68 | // Internals 69 | // 70 | 71 | private function completionSignalingHandler(event:Event):void 72 | { 73 | dispatchEvent(new Event(Event.COMPLETE)); 74 | } 75 | 76 | private function errorHandler(event:Event):void 77 | { 78 | dispatchEvent(event.clone()); 79 | 80 | // Uncomment the line below to see the global exception handling in action. 81 | //throw new Error("Failed to load XML file at " + url); 82 | } 83 | 84 | private var loader:URLLoader; 85 | private var url:String; 86 | } 87 | } -------------------------------------------------------------------------------- /src/org/osmf/player/debug/LogMessage.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | * 19 | **********************************************************/ 20 | 21 | package org.osmf.player.debug 22 | { 23 | /** 24 | * LogMessage stores the information related to a log call. 25 | */ 26 | public class LogMessage 27 | { 28 | public function LogMessage( level:String, 29 | category:String, 30 | message:String, 31 | params:Array, 32 | timestamp:Date = null) 33 | { 34 | _category = category; 35 | _level = level; 36 | _message = message; 37 | _params = params; 38 | if (timestamp == null) 39 | { 40 | _timestamp = new Date(); 41 | } 42 | else 43 | { 44 | _timestamp = timestamp; 45 | } 46 | } 47 | 48 | public function get formatedMessage():String 49 | { 50 | var result:String = message; 51 | var numParams:int = params.length; 52 | 53 | for (var i:int = 0; i < numParams; i++) 54 | { 55 | result = result.replace(new RegExp("\\{" + i + "\\}", "g"), params[i]); 56 | } 57 | 58 | return result; 59 | } 60 | 61 | public function get formatedTimestamp():String 62 | { 63 | return _timestamp.toLocaleString(); 64 | } 65 | public function get params():Array 66 | { 67 | return _params; 68 | } 69 | 70 | public function get message():String 71 | { 72 | return _message; 73 | } 74 | 75 | public function get category():String 76 | { 77 | return _category; 78 | } 79 | 80 | public function get level():String 81 | { 82 | return _level; 83 | } 84 | 85 | public function get timestamp():Date 86 | { 87 | return _timestamp; 88 | } 89 | 90 | public function toString():String 91 | { 92 | return formatedTimestamp +" [" + level + "] " + category + " " + formatedMessage; 93 | } 94 | 95 | private var _level:String; 96 | private var _category:String; 97 | private var _message:String; 98 | private var _params:Array; 99 | private var _timestamp:Date; 100 | } 101 | } -------------------------------------------------------------------------------- /src/org/osmf/player/debug/StrobeLoggerFactory.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | * 19 | **********************************************************/ 20 | 21 | package org.osmf.player.debug 22 | { 23 | import flash.utils.Dictionary; 24 | 25 | import org.osmf.logging.Logger; 26 | import org.osmf.logging.LoggerFactory; 27 | 28 | /** 29 | * StrobeLoggerFactory is needed for hooking into the OSMF logging framework. 30 | */ 31 | public class StrobeLoggerFactory extends LoggerFactory 32 | { 33 | public function StrobeLoggerFactory(logHandler:LogHandler) 34 | { 35 | loggers = new Dictionary(); 36 | this.logHandler = logHandler; 37 | } 38 | 39 | /** 40 | * @inheritDoc 41 | * 42 | * @langversion 3.0 43 | * @playerversion Flash 10 44 | * @playerversion AIR 1.5 45 | * @productversion OSMF 1.0 46 | */ 47 | override public function getLogger(name:String):Logger 48 | { 49 | var logger:Logger = loggers[name]; 50 | 51 | if (logger == null) 52 | { 53 | logger = new StrobeLogger(name, logHandler); 54 | loggers[name] = logger; 55 | } 56 | 57 | return logger; 58 | } 59 | 60 | // internal 61 | // 62 | 63 | private var loggers:Dictionary; 64 | private var logHandler:LogHandler; 65 | } 66 | } -------------------------------------------------------------------------------- /src/org/osmf/player/debug/qos/BufferIndicators.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | * 19 | **********************************************************/ 20 | 21 | package org.osmf.player.debug.qos 22 | { 23 | 24 | /** 25 | * Stores the qos indicators related to Buffering. 26 | */ 27 | public class BufferIndicators extends IndicatorsBase 28 | { 29 | public var percentage:Number = 0; 30 | public var time:Number = 0; 31 | public var length:Number = 0; 32 | public var eventCount:uint = 0; 33 | public var avgWaitDuration:Number = 0; 34 | public var totalWaitDuration:Number = 0; 35 | public var previousWaitDuration:Number = 0; 36 | public var maxWaitDuration:Number = 0; 37 | 38 | override protected function getOrderedFieldList():Array 39 | { 40 | return [ 41 | "percentage", 42 | "time", 43 | "length", 44 | "eventCount", 45 | "avgWaitDuration", 46 | "totalWaitDuration", 47 | "previousWaitDuration", 48 | "maxWaitDuration" 49 | ]; 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /src/org/osmf/player/debug/qos/DynamicStreamingIndicators.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | * 19 | **********************************************************/ 20 | package org.osmf.player.debug.qos 21 | { 22 | 23 | /** 24 | * Stores the qos indicators related to DynamicStreaming. 25 | */ 26 | public class DynamicStreamingIndicators extends IndicatorsBase 27 | { 28 | public var index:uint; 29 | public var numDynamicStreams:uint; 30 | public var currentBitrate:uint; 31 | public var previousSwitchDuration:Number; 32 | public var totalSwitchDuration:Number = 0; 33 | public var dsSwitchEventCount:uint; 34 | public var avgSwitchDuration:Number; 35 | public var currentVerticalResolution:Number; 36 | public var bestVerticalResolution:Number; 37 | public var bestHorizontatalResolution:Number; 38 | 39 | public var targetIndex:int; 40 | public var targetBitrate:Number; 41 | override protected function getOrderedFieldList():Array 42 | { 43 | return [ 44 | "index", 45 | "numDynamicStreams", 46 | "currentBitrate", 47 | "previousSwitchDuration", 48 | "totalSwitchDuration", 49 | "dsSwitchEventCount", 50 | "avgSwitchDuration", 51 | "currentVerticalResolution", 52 | "bestVerticalResolution", 53 | "bestHorizontatalResolution" 54 | ]; 55 | } 56 | } 57 | } -------------------------------------------------------------------------------- /src/org/osmf/player/debug/qos/IndicatorsBase.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | * 19 | **********************************************************/ 20 | 21 | package org.osmf.player.debug.qos 22 | { 23 | import flash.utils.Dictionary; 24 | 25 | import org.osmf.player.chrome.configuration.ConfigurationUtils; 26 | 27 | /** 28 | * Base class for StrobeMediaPlayer indicators. 29 | * 30 | * Currently is responsible for assembling the list of public properties. 31 | */ 32 | public class IndicatorsBase 33 | { 34 | public function getFields():Array 35 | { 36 | var result:Array = getOrderedFieldList(); 37 | var filter:Array = getFilterFieldList(); 38 | var fields:Dictionary = ConfigurationUtils.retrieveFields(this, false); 39 | var nonOrderedFields:Array = new Array(); 40 | for (var fieldName:String in fields) 41 | { 42 | if (filter.indexOf(fieldName) <0 && result.indexOf(fieldName) < 0) 43 | { 44 | nonOrderedFields.push(fieldName); 45 | } 46 | } 47 | nonOrderedFields.sort(); 48 | result = result.concat(nonOrderedFields); 49 | return result; 50 | } 51 | 52 | protected function getOrderedFieldList():Array 53 | { 54 | return []; 55 | } 56 | 57 | protected function getFilterFieldList():Array 58 | { 59 | return []; 60 | } 61 | } 62 | } -------------------------------------------------------------------------------- /src/org/osmf/player/debug/qos/QoSDashboard.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | * 19 | **********************************************************/ 20 | 21 | package org.osmf.player.debug.qos 22 | { 23 | /** 24 | * The QoS Dashboard groups all the QoS indicators. 25 | */ 26 | public class QoSDashboard extends IndicatorsBase 27 | { 28 | public var duration:Number; 29 | public var currentTime:Number; 30 | public var downloadRatio:Number; 31 | public var downloadKbps:Number; 32 | public var playbackKbps:Number; 33 | public var lsoDownloadKbps:Number; 34 | public var memory:Number; 35 | public var droppedFrames:uint; 36 | public var avgDroppedFPS:Number; 37 | 38 | public var streamType:String; 39 | 40 | public var buffer:BufferIndicators = new BufferIndicators(); 41 | public var rendering:RenderingIndicators = new RenderingIndicators(); 42 | public var ds:DynamicStreamingIndicators = new DynamicStreamingIndicators(); 43 | 44 | // Protected 45 | // 46 | 47 | override protected function getOrderedFieldList():Array 48 | { 49 | return [ 50 | "duration", 51 | "currentTime", 52 | "downloadRatio", 53 | "downloadKbps", 54 | "playbackKbps", 55 | "lsoDownloadKbps", 56 | "memory", 57 | "droppedFrames", 58 | "avgDroppedFPS" 59 | ]; 60 | } 61 | 62 | } 63 | } -------------------------------------------------------------------------------- /src/org/osmf/player/debug/qos/RenderingIndicators.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | * 19 | **********************************************************/ 20 | 21 | package org.osmf.player.debug.qos 22 | { 23 | 24 | /** 25 | * Stores the qos indicators related to Rendering. 26 | */ 27 | public class RenderingIndicators extends IndicatorsBase 28 | { 29 | public var width:uint; 30 | public var height:uint; 31 | public var aspectRatio:Number; 32 | public var displayObjectWidth:Number; 33 | public var displayObjectHeight:Number; 34 | public var displayObjectRatio:Number; 35 | public var HD:Boolean; 36 | public var smoothing:Boolean; 37 | public var deblocking:String; 38 | public var fullScreenSourceRect:String; 39 | public var fullScreenSourceRectAspectRatio:Number; 40 | public var screenWidth:Number; 41 | public var screenHeight:Number; 42 | public var screenAspectRatio:Number; 43 | 44 | override protected function getOrderedFieldList():Array 45 | { 46 | return [ 47 | "width", 48 | "height", 49 | "aspectRatio", 50 | "displayObjectWidth", 51 | "displayObjectHeight", 52 | "displayObjectRatio", 53 | "HD", 54 | "smoothing", 55 | "deblocking", 56 | "fullScreenSourceRect", 57 | "fullScreenSourceRectAspectRatio", 58 | "screenWidth", 59 | "screenHeight", 60 | "screenAspectRatio", 61 | ]; 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /src/org/osmf/player/elements/AlertDialogElement.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | * 19 | **********************************************************/ 20 | 21 | package org.osmf.player.elements 22 | { 23 | import flash.display.DisplayObject; 24 | 25 | import org.osmf.player.chrome.assets.AssetsManager; 26 | import org.osmf.player.chrome.configuration.WidgetsParser; 27 | import org.osmf.player.chrome.widgets.AlertDialog; 28 | import org.osmf.layout.LayoutMetadata; 29 | import org.osmf.media.MediaElement; 30 | import org.osmf.traits.DisplayObjectTrait; 31 | import org.osmf.traits.MediaTraitType; 32 | import org.osmf.player.chrome.ChromeProvider; 33 | 34 | /** 35 | * AlertDialogElement is a MediaElement wrapper for an AlertDialog widget. 36 | */ 37 | public class AlertDialogElement extends MediaElement 38 | { 39 | // Public interface 40 | // 41 | 42 | public function alert(caption:String, message:String):void 43 | { 44 | alertDialog.alert(caption, message) 45 | } 46 | 47 | 48 | public function set tintColor(value:uint):void 49 | { 50 | alertDialog.tintColor = value; 51 | } 52 | 53 | // Overrides 54 | 55 | override protected function setupTraits():void 56 | { 57 | // Setup a AlertDialog using the ChromeLibrary based ChromeProvider: 58 | chromeProvider = ChromeProvider.getInstance(); 59 | chromeProvider.createAlertDialog(); 60 | alertDialog = chromeProvider.getWidget("alert") as AlertDialog; 61 | alertDialog.measure(); 62 | 63 | // Use the alert dialog's layout metadata as the element's layout metadata: 64 | addMetadata(LayoutMetadata.LAYOUT_NAMESPACE, alertDialog.layoutMetadata); 65 | 66 | // Signal that this media element is viewable: create a DisplayObjectTrait. 67 | // Assign alert (which is a Sprite) to be our view's displayObject. 68 | // Additionally, use its current width and height for the trait's mediaWidth 69 | // and mediaHeight properties: 70 | var viewable:DisplayObjectTrait = new DisplayObjectTrait(alertDialog, alertDialog.measuredWidth, alertDialog.measuredHeight); 71 | // Add the trait: 72 | addTrait(MediaTraitType.DISPLAY_OBJECT, viewable); 73 | 74 | super.setupTraits(); 75 | } 76 | 77 | // Internals 78 | 79 | private var chromeProvider:ChromeProvider; 80 | 81 | private var _target:MediaElement; 82 | private var alertDialog:AlertDialog; 83 | } 84 | } -------------------------------------------------------------------------------- /src/org/osmf/player/elements/AuthenticationDialogElement.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | * 19 | **********************************************************/ 20 | 21 | package org.osmf.player.elements 22 | { 23 | import org.osmf.player.chrome.widgets.AuthenticationDialog; 24 | import org.osmf.layout.LayoutMetadata; 25 | import org.osmf.media.MediaElement; 26 | import org.osmf.metadata.Metadata; 27 | import org.osmf.player.chrome.ChromeProvider; 28 | import org.osmf.traits.DisplayObjectTrait; 29 | import org.osmf.traits.MediaTraitType; 30 | 31 | /** 32 | * AuthenticationDialogElement is a MediaElement wrapper for a AuthentificationDialog widget. 33 | */ 34 | public class AuthenticationDialogElement extends MediaElement 35 | { 36 | 37 | // Public interface 38 | // 39 | 40 | /** 41 | * The target media element for the authentication dialog 42 | * 43 | * @langversion 3.0 44 | * @playerversion Flash 10 45 | * @playerversion AIR 1.5 46 | * @productversion OSMF 1.0 47 | */ 48 | public function set target(value:MediaElement):void 49 | { 50 | authDialog.media = value; 51 | } 52 | 53 | public function set tintColor(value:uint):void 54 | { 55 | authDialog.tintColor = value; 56 | } 57 | 58 | // Overrides 59 | // 60 | 61 | override protected function setupTraits():void 62 | { 63 | // Setup a AuthenticationDialog using the ChromeLibrary based ChromeProvider: 64 | chromeProvider = ChromeProvider.getInstance(); 65 | chromeProvider.createAuthenticationDialog(); 66 | authDialog = chromeProvider.getWidget("login") as AuthenticationDialog; 67 | authDialog.measure(); 68 | 69 | // Use the alert dialog's layout metadata as the element's layout metadata: 70 | addMetadata(LayoutMetadata.LAYOUT_NAMESPACE, authDialog.layoutMetadata); 71 | 72 | // Signal that this media element is viewable: create a DisplayObjectTrait. 73 | // Assign auth dialog (which is a Sprite) to be our view's displayObject. 74 | // Additionally, use its current width and height for the trait's mediaWidth 75 | // and mediaHeight properties: 76 | var viewable:DisplayObjectTrait = new DisplayObjectTrait(authDialog, authDialog.measuredWidth, authDialog.measuredHeight); 77 | // Add the trait: 78 | addTrait(MediaTraitType.DISPLAY_OBJECT, viewable); 79 | 80 | super.setupTraits(); 81 | } 82 | 83 | // Internals 84 | // 85 | 86 | private var chromeProvider:ChromeProvider; 87 | 88 | private var _target:MediaElement; 89 | private var authDialog:AuthenticationDialog; 90 | } 91 | } -------------------------------------------------------------------------------- /src/org/osmf/player/elements/ErrorElement.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | * 19 | **********************************************************/ 20 | 21 | package org.osmf.player.elements 22 | { 23 | import flash.display.DisplayObject; 24 | import flash.display.Graphics; 25 | import flash.display.Sprite; 26 | 27 | import org.osmf.player.chrome.assets.AssetsManager; 28 | import org.osmf.player.chrome.widgets.LabelWidget; 29 | import org.osmf.layout.LayoutMetadata; 30 | import org.osmf.layout.VerticalAlign; 31 | import org.osmf.media.MediaElement; 32 | import org.osmf.player.chrome.ChromeProvider; 33 | import org.osmf.traits.DisplayObjectTrait; 34 | import org.osmf.traits.PlayTrait; 35 | import org.osmf.traits.SeekTrait; 36 | import org.osmf.traits.TimeTrait; 37 | 38 | /** 39 | * Defines a media element that displays an error. The element is used 40 | * with play lists: if an element runs into trouble, the original element 41 | * is removed, and this error element is inserted in its place. 42 | * 43 | * An error element has a time trait: it plays for 5 seconds. 44 | */ 45 | public class ErrorElement extends MediaElement 46 | { 47 | // Public Interface 48 | // 49 | 50 | public function ErrorElement(errorMessage:String) 51 | { 52 | this.errorMessage = errorMessage; 53 | 54 | super(); 55 | } 56 | 57 | // Overrides 58 | // 59 | 60 | override protected function setupTraits():void 61 | { 62 | super.setupTraits(); 63 | 64 | // Setup a AlertDialog using the ChromeLibrary based ChromeProvider: 65 | var chromeProvider:ChromeProvider = ChromeProvider.getInstance(); 66 | chromeProvider.createErrorWidget(); 67 | var errorWidget:ErrorWidget = chromeProvider.getWidget("error") as ErrorWidget; 68 | errorWidget.errorMessage = errorMessage; 69 | errorWidget.measure(); 70 | 71 | // Make the widget's layout metadata, the element's metadata: 72 | addMetadata(LayoutMetadata.LAYOUT_NAMESPACE, errorWidget.layoutMetadata); 73 | 74 | // Add a view trait, using the widget's display object: 75 | var viewable:DisplayObjectTrait = new DisplayObjectTrait(errorWidget, errorWidget.measuredWidth, errorWidget.measuredHeight); 76 | addTrait(viewable.traitType, viewable); 77 | 78 | } 79 | 80 | // Internals 81 | // 82 | 83 | private var errorMessage:String; 84 | } 85 | } -------------------------------------------------------------------------------- /src/org/osmf/player/elements/ErrorWidget.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | * 19 | **********************************************************/ 20 | 21 | package org.osmf.player.elements 22 | { 23 | import org.osmf.player.chrome.assets.AssetsManager; 24 | import org.osmf.player.chrome.widgets.LabelWidget; 25 | import org.osmf.player.chrome.widgets.Widget; 26 | 27 | public class ErrorWidget extends Widget 28 | { 29 | // Public Interface 30 | // 31 | 32 | public function set errorMessage(value:String):void 33 | { 34 | errorLabel.text = value; 35 | } 36 | 37 | // Overrides 38 | // 39 | 40 | override public function configure(xml:XML, assetManager:AssetsManager):void 41 | { 42 | super.configure(xml, assetManager); 43 | 44 | errorLabel = getChildWidget("errorLabel") as LabelWidget; 45 | } 46 | 47 | // Internals 48 | // 49 | 50 | private var errorLabel:LabelWidget; 51 | } 52 | } -------------------------------------------------------------------------------- /src/org/osmf/player/elements/PlaylistElement.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | * 19 | **********************************************************/ 20 | 21 | package org.osmf.player.elements 22 | { 23 | import flash.events.Event; 24 | 25 | import org.osmf.elements.LoadFromDocumentElement; 26 | import org.osmf.events.MetadataEvent; 27 | import org.osmf.media.MediaFactory; 28 | import org.osmf.metadata.Metadata; 29 | import org.osmf.net.StreamType; 30 | import org.osmf.player.elements.playlistClasses.PlaylistLoader; 31 | import org.osmf.player.elements.playlistClasses.PlaylistMetadata; 32 | import org.osmf.player.elements.playlistClasses.ProxyMetadataEx; 33 | 34 | /** 35 | * Defines a media element that reads a playlist (so far the only supported 36 | * format is m3u) and represents the media in the playlist sequentially. 37 | * 38 | * The class monitors its metadata for "gotoNext" and "gotoPrevious" values 39 | * being set to true on its PlaylistMetadata object. 40 | * 41 | * Since this class is LoadFromDocumentElement derived, we need an inner 42 | * element that acts as the proxied element. This object is of type 43 | * InnerPlaylistElement. Refer to PlaylistLoader to see the inner object 44 | * instantiated. 45 | */ 46 | public class PlaylistElement extends LoadFromDocumentElement 47 | { 48 | /** 49 | * Constructor. 50 | * 51 | * @loader The loader that the playlist element should use. When null, 52 | * a PlaylistLoader instance is used. 53 | */ 54 | public function PlaylistElement(loader:PlaylistLoader = null) 55 | { 56 | this.loader = loader || new PlaylistLoader(); 57 | loader.addEventListener(Event.COMPLETE, onLoaderComplete); 58 | 59 | super(null, loader); 60 | } 61 | 62 | /** 63 | * Override that plugs in workaround class ProxyMetadataEx, that fixes OSMF 64 | * bug 933. 65 | */ 66 | override protected function createMetadata():Metadata 67 | { 68 | return new ProxyMetadataEx(); 69 | } 70 | 71 | // Internals 72 | // 73 | 74 | private var loader:PlaylistLoader; 75 | private var playlistMetadata:PlaylistMetadata; 76 | 77 | private function onLoaderComplete(event:Event):void 78 | { 79 | // Watch for metadata value changes: a change to the value under keys 80 | // "gotoNext" or "gotoPrevious" will result in the next or previous 81 | // element being activated. 82 | playlistMetadata = loader.playlistMetadata; 83 | playlistMetadata.addEventListener(MetadataEvent.VALUE_CHANGE, onMetadataValueChange); 84 | 85 | metadata.addValue(PlaylistMetadata.NAMESPACE, playlistMetadata); 86 | } 87 | 88 | private function onMetadataValueChange(event:MetadataEvent):void 89 | { 90 | if (event.key == PlaylistMetadata.GOTO_NEXT && event.value == true) 91 | { 92 | // Lower the flag: 93 | playlistMetadata.addValue(PlaylistMetadata.GOTO_NEXT, false); 94 | loader.playlistElement.activateNextElement(); 95 | } 96 | else if (event.key == PlaylistMetadata.GOTO_PREVIOUS && event.value == true) 97 | { 98 | // Lower the flag: 99 | playlistMetadata.addValue(PlaylistMetadata.GOTO_PREVIOUS, false); 100 | loader.playlistElement.activatePreviousElement(); 101 | } 102 | } 103 | 104 | } 105 | } -------------------------------------------------------------------------------- /src/org/osmf/player/elements/playlistClasses/PlaylistParser.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | * 19 | **********************************************************/ 20 | 21 | package org.osmf.player.elements.playlistClasses 22 | { 23 | import org.osmf.media.MediaResourceBase; 24 | import org.osmf.media.URLResource; 25 | import org.osmf.net.StreamType; 26 | import org.osmf.net.StreamingURLResource; 27 | 28 | /** 29 | * Defines a parser for the M3U plain playlist format (non-extended). All lines 30 | * describe a resource, except for lines that are blank, or start with a pound 31 | * sign. 32 | */ 33 | internal class PlaylistParser 34 | { 35 | public function PlaylistParser(resourceConstructorFunction:Function = null) 36 | { 37 | this.resourceConstructorFunction = resourceConstructorFunction || this.resourceConstructorFunction; 38 | } 39 | 40 | public function parse(value:String):Vector. 41 | { 42 | var result:Vector.; 43 | 44 | if (value) 45 | { 46 | var lines:Array = value.split(/\r?\n/g); 47 | for each (var line:String in lines) 48 | { 49 | if (line && line.length) 50 | { 51 | if (line.charAt(0) != "#") 52 | { 53 | // This is a resource: add it to the result: 54 | result ||= new Vector.(); 55 | var resource:StreamingURLResource = resourceConstructorFunction(line); 56 | result.push(new URLResource(line)); 57 | } 58 | } 59 | } 60 | } 61 | 62 | if (result == null || result.length == 0) 63 | { 64 | throw new Error("Playlist contains no resources"); 65 | } 66 | 67 | return result; 68 | } 69 | 70 | // Internals 71 | // 72 | 73 | private var resourceConstructorFunction:Function = constructResource; 74 | 75 | private function constructResource(url:String):MediaResourceBase 76 | { 77 | return new StreamingURLResource(url, StreamType.LIVE_OR_RECORDED); 78 | } 79 | } 80 | } -------------------------------------------------------------------------------- /src/org/osmf/player/elements/playlistClasses/PlaylistTimeTrait.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | * 19 | **********************************************************/ 20 | 21 | package org.osmf.player.elements.playlistClasses 22 | { 23 | import flash.events.Event; 24 | 25 | import org.osmf.events.MediaElementEvent; 26 | import org.osmf.events.TimeEvent; 27 | import org.osmf.media.MediaElement; 28 | import org.osmf.traits.MediaTraitType; 29 | import org.osmf.traits.TimeTrait; 30 | 31 | /** 32 | * Defines the time trait for a playlist element. Serves to keep state when the active 33 | * media element of a playlist changes from one to the next. 34 | */ 35 | internal class PlaylistTimeTrait extends TimeTrait 36 | { 37 | public function PlaylistTimeTrait(duration:Number=NaN) 38 | { 39 | super(duration); 40 | } 41 | 42 | public function set mediaElement(value:MediaElement):void 43 | { 44 | if (value != _mediaElement) 45 | { 46 | if (_mediaElement) 47 | { 48 | _mediaElement.removeEventListener(MediaElementEvent.TRAIT_ADD, onMediaElementTraitsChange); 49 | _mediaElement.removeEventListener(MediaElementEvent.TRAIT_REMOVE, onMediaElementTraitsChange); 50 | } 51 | 52 | _mediaElement = value; 53 | 54 | if (_mediaElement) 55 | { 56 | _mediaElement.addEventListener(MediaElementEvent.TRAIT_ADD, onMediaElementTraitsChange); 57 | _mediaElement.addEventListener(MediaElementEvent.TRAIT_REMOVE, onMediaElementTraitsChange); 58 | } 59 | 60 | updateTimeTrait(); 61 | } 62 | } 63 | 64 | public function get enabled():Boolean 65 | { 66 | return _timeTrait != null; 67 | } 68 | 69 | public function signalCompletion():void 70 | { 71 | signalComplete(); 72 | } 73 | 74 | // Overrides 75 | // 76 | 77 | override public function get currentTime():Number 78 | { 79 | return _timeTrait ? _timeTrait.currentTime : 0; 80 | } 81 | 82 | // Internals 83 | // 84 | 85 | private var _mediaElement:MediaElement; 86 | private var _timeTrait:TimeTrait; 87 | 88 | private function set timeTrait(value:TimeTrait):void 89 | { 90 | if (value != _timeTrait) 91 | { 92 | var oldTrait:TimeTrait = _timeTrait; 93 | _timeTrait = value; 94 | 95 | if (!(_timeTrait && oldTrait)) 96 | { 97 | dispatchEvent(new PlaylistTraitEvent(PlaylistTraitEvent.ENABLED_CHANGE)); 98 | } 99 | } 100 | } 101 | 102 | private function onMediaElementTraitsChange(event:MediaElementEvent):void 103 | { 104 | updateTimeTrait 105 | ( event.type == MediaElementEvent.TRAIT_REMOVE 106 | && event.traitType == MediaTraitType.TIME 107 | ); 108 | } 109 | 110 | private function updateTimeTrait(pendingRemoval:Boolean = false):void 111 | { 112 | var newTimeTrait:TimeTrait 113 | = _mediaElement 114 | ? pendingRemoval 115 | ? null 116 | : _mediaElement.getTrait(MediaTraitType.TIME) as TimeTrait 117 | : null; 118 | 119 | if (_timeTrait != newTimeTrait) 120 | { 121 | if (_timeTrait) 122 | { 123 | _timeTrait.removeEventListener(TimeEvent.COMPLETE, onTimeTraitComplete); 124 | _timeTrait.removeEventListener(TimeEvent.DURATION_CHANGE, onTimeTraitDurationChange); 125 | } 126 | 127 | timeTrait = newTimeTrait; 128 | 129 | if (_timeTrait) 130 | { 131 | _timeTrait.addEventListener(TimeEvent.COMPLETE, onTimeTraitComplete); 132 | _timeTrait.addEventListener(TimeEvent.DURATION_CHANGE, onTimeTraitDurationChange); 133 | 134 | setDuration(_timeTrait.duration); 135 | } 136 | else 137 | { 138 | setDuration(NaN); 139 | } 140 | } 141 | } 142 | 143 | private function onTimeTraitComplete(event:TimeEvent):void 144 | { 145 | dispatchEvent(new PlaylistTraitEvent(PlaylistTraitEvent.ACTIVE_ITEM_COMPLETE)); 146 | } 147 | 148 | private function onTimeTraitDurationChange(event:TimeEvent):void 149 | { 150 | setDuration(event.time); 151 | } 152 | } 153 | } -------------------------------------------------------------------------------- /src/org/osmf/player/elements/playlistClasses/PlaylistTraitEvent.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | * 19 | **********************************************************/ 20 | 21 | package org.osmf.player.elements.playlistClasses 22 | { 23 | import flash.events.Event; 24 | 25 | /** 26 | * Defines the event object and types as used by the custom traits that 27 | * InnerPlaylistElement uses. 28 | */ 29 | internal class PlaylistTraitEvent extends Event 30 | { 31 | public static const ACTIVE_ITEM_COMPLETE:String = "lastItemComplete"; 32 | public static const ENABLED_CHANGE:String = "enabledChange"; 33 | 34 | public function PlaylistTraitEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false) 35 | { 36 | super(type, bubbles, cancelable); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /src/org/osmf/player/elements/playlistClasses/ProxyMetadataEx.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | * 19 | **********************************************************/ 20 | 21 | // NB: 22 | // This is a monkey-patched version of the OSMF's ProxyMetadata, fixing bug FM-933. 23 | 24 | package org.osmf.player.elements.playlistClasses 25 | { 26 | import __AS3__.vec.Vector; 27 | 28 | import flash.events.Event; 29 | 30 | import org.osmf.metadata.Metadata; 31 | import org.osmf.events.MetadataEvent; 32 | import org.osmf.elements.proxyClasses.ProxyMetadata; 33 | 34 | [ExcludeClass] 35 | 36 | /** 37 | * @private 38 | * 39 | * Internal class used by the FactoryElement to proxy metadata. 40 | */ 41 | public class ProxyMetadataEx extends ProxyMetadata 42 | { 43 | public function ProxyMetadataEx() 44 | { 45 | super(); 46 | 47 | proxiedMetadata = new Metadata(); 48 | 49 | // The listeners below don't get added by the original class, and fix 50 | // initial changes not being dispatched: 51 | proxiedMetadata.addEventListener(MetadataEvent.VALUE_ADD, redispatchEvent); 52 | proxiedMetadata.addEventListener(MetadataEvent.VALUE_CHANGE, redispatchEvent); 53 | proxiedMetadata.addEventListener(MetadataEvent.VALUE_REMOVE, redispatchEvent); 54 | } 55 | 56 | override public function set metadata(value:Metadata):void 57 | { 58 | 59 | // Transfer all old values to new: 60 | for each (var url:String in proxiedMetadata.keys) 61 | { 62 | value.addValue(url, proxiedMetadata.getValue(url)); 63 | } 64 | proxiedMetadata = value; 65 | proxiedMetadata.addEventListener(MetadataEvent.VALUE_ADD, redispatchEvent); 66 | proxiedMetadata.addEventListener(MetadataEvent.VALUE_CHANGE, redispatchEvent); 67 | proxiedMetadata.addEventListener(MetadataEvent.VALUE_REMOVE, redispatchEvent); 68 | } 69 | 70 | /** 71 | * @private 72 | */ 73 | override public function getValue(key:String):* 74 | { 75 | return proxiedMetadata.getValue(key); 76 | } 77 | 78 | /** 79 | * @private 80 | */ 81 | override public function addValue(key:String, value:Object):void 82 | { 83 | proxiedMetadata.addValue(key, value); 84 | } 85 | 86 | /** 87 | * @private 88 | */ 89 | override public function removeValue(key:String):* 90 | { 91 | return proxiedMetadata.removeValue(key); 92 | } 93 | 94 | /** 95 | * @private 96 | */ 97 | override public function get keys():Vector. 98 | { 99 | return proxiedMetadata.keys; 100 | } 101 | 102 | private function redispatchEvent(event:Event):void 103 | { 104 | dispatchEvent(event.clone()); 105 | } 106 | 107 | private var proxiedMetadata:Metadata; 108 | } 109 | } -------------------------------------------------------------------------------- /src/org/osmf/player/errors/StrobePlayerError.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | * 19 | **********************************************************/ 20 | 21 | package org.osmf.player.errors 22 | { 23 | import org.osmf.events.MediaError; 24 | import org.osmf.utils.OSMFStrings; 25 | 26 | /** 27 | * Defines the error object as used by the player on throwing 28 | * exceptions. 29 | */ 30 | public class StrobePlayerError extends Error 31 | { 32 | public function StrobePlayerError(errorID:int, detail:String=null) 33 | { 34 | super(getMessageForErrorID(errorID), errorID); 35 | 36 | _detail = detail; 37 | } 38 | 39 | /** 40 | * An optional string that contains supporting detail for the error. 41 | * Typically this string is simply the error detail provided by a 42 | * Flash Player API. 43 | * 44 | * @langversion 3.0 45 | * @playerversion Flash 10 46 | * @playerversion AIR 1.5 47 | * @productversion OSMF 1.0 48 | */ 49 | public function get detail():String 50 | { 51 | return _detail; 52 | } 53 | 54 | // Protected 55 | // 56 | 57 | /** 58 | * Returns the message for the error with the specified ID. If 59 | * the error ID is unknown, returns the empty string. 60 | * 61 | *

Subclasses should override to provide messages for their 62 | * custom errors, as this method returns the value that is exposed in 63 | * the message property.

64 | * 65 | * @param errorID The ID for the error. 66 | * 67 | * @return The message for the error with the specified error ID. 68 | * 69 | * @langversion 3.0 70 | * @playerversion Flash 10 71 | * @playerversion AIR 1.5 72 | * @productversion OSMF 1.0 73 | */ 74 | protected function getMessageForErrorID(errorID:int):String 75 | { 76 | return StrobePlayerErrorCodes.getMessageForErrorID(errorID); 77 | } 78 | 79 | // Internals 80 | // 81 | 82 | private var _detail:String; 83 | } 84 | } -------------------------------------------------------------------------------- /src/org/osmf/player/errors/StrobePlayerErrorCodes.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | * 19 | **********************************************************/ 20 | 21 | package org.osmf.player.errors 22 | { 23 | import org.osmf.player.utils.StrobePlayerStrings; 24 | import org.osmf.utils.OSMFStrings; 25 | 26 | /** 27 | * Defines the error codes as used on error messages generated by the 28 | * player. 29 | */ 30 | public class StrobePlayerErrorCodes 31 | { 32 | public static const ILLEGAL_INPUT_VARIABLE:int = 1000; 33 | public static const DYNAMIC_STREAMING_RESOURCE_EXPECTED:int = 1001; 34 | public static const CONFIGURATION_LOAD_ERROR:int = 1002; 35 | public static const UNKNOWN_ERROR:int = 1003; 36 | public static const PLUGIN_NOT_IN_WHITELIST:int = 1004; 37 | public static const PLUGIN_LOAD_FAILED:int = 1005; 38 | 39 | /** 40 | * @private 41 | * 42 | * Returns a message for the error of the specified ID. If the error ID 43 | * is unknown, returns the empty string. 44 | * 45 | * @param errorID The ID for the error. 46 | * 47 | * @return The message for the error with the specified ID. 48 | * 49 | * @langversion 3.0 50 | * @playerversion Flash 10 51 | * @playerversion AIR 1.5 52 | * @productversion OSMF 1.0 53 | */ 54 | internal static function getMessageForErrorID(errorID:int):String 55 | { 56 | var message:String = ""; 57 | 58 | for (var i:int = 0; i < errorMap.length; i++) 59 | { 60 | if (errorMap[i].errorID == errorID) 61 | { 62 | message = StrobePlayerStrings.getString(errorMap[i].message); 63 | break; 64 | } 65 | } 66 | 67 | return message; 68 | } 69 | 70 | private static const errorMap:Array 71 | = [ { errorID:ILLEGAL_INPUT_VARIABLE 72 | , message:StrobePlayerStrings.ILLEGAL_INPUT_VARIABLE 73 | } 74 | , { errorID:DYNAMIC_STREAMING_RESOURCE_EXPECTED 75 | , message:StrobePlayerStrings.DYNAMIC_STREAMING_RESOURCE_EXPECTED 76 | } 77 | , { errorID:CONFIGURATION_LOAD_ERROR 78 | , message:StrobePlayerStrings.CONFIGURATION_LOAD_ERROR 79 | } 80 | , { errorID:PLUGIN_NOT_IN_WHITELIST 81 | , message:StrobePlayerStrings.PLUGIN_NOT_IN_WHITELIST 82 | } 83 | ]; 84 | } 85 | } -------------------------------------------------------------------------------- /src/org/osmf/player/media/VideoElementRegistry.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | * 19 | **********************************************************/ 20 | 21 | package org.osmf.player.media 22 | { 23 | import flash.errors.IllegalOperationError; 24 | import flash.filters.DisplacementMapFilter; 25 | import flash.net.NetStream; 26 | import flash.utils.Dictionary; 27 | 28 | import org.osmf.player.chrome.utils.MediaElementUtils; 29 | import org.osmf.elements.VideoElement; 30 | import org.osmf.media.MediaResourceBase; 31 | import org.osmf.net.*; 32 | import org.osmf.net.StreamingURLResource; 33 | import org.osmf.traits.MediaTraitType; 34 | 35 | /** 36 | * @private 37 | */ 38 | public class VideoElementRegistry 39 | { 40 | // Public Interface 41 | // 42 | 43 | /* static */ 44 | public static function getInstance():VideoElementRegistry 45 | { 46 | instance ||= new VideoElementRegistry(ConstructorLock); 47 | return instance; 48 | } 49 | 50 | public function VideoElementRegistry(lock:Class = null):void 51 | { 52 | if (lock != ConstructorLock) 53 | { 54 | throw new IllegalOperationError("VideoElementRegistry is a singleton: use getInstance to obtain a reference."); 55 | } 56 | 57 | // Use weak references - we not interested in GC instances. 58 | _videoElements = new Dictionary(true); 59 | } 60 | 61 | public function register(videoElement:VideoElement):void 62 | { 63 | _videoElements[videoElement] = true; 64 | } 65 | 66 | public function retriveMediaElementByNetStream(netStream:NetStream):VideoElement 67 | { 68 | var result:VideoElement; 69 | for (var key:Object in _videoElements) 70 | { 71 | var videoElement:VideoElement = key as VideoElement; 72 | var loadTrait:NetStreamLoadTrait = videoElement.getTrait(MediaTraitType.LOAD) as NetStreamLoadTrait; 73 | if (loadTrait.netStream == netStream) 74 | { 75 | return videoElement; 76 | } 77 | } 78 | return result; 79 | } 80 | 81 | // Internals 82 | // 83 | private static var instance:VideoElementRegistry; 84 | 85 | private var _videoElements:Dictionary; 86 | } 87 | } 88 | 89 | class ConstructorLock {}; -------------------------------------------------------------------------------- /src/org/osmf/player/metadata/MediaMetadata.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | * 19 | **********************************************************/ 20 | 21 | package org.osmf.player.metadata 22 | { 23 | import flash.net.NetConnection; 24 | CONFIG::FLASH_10_1 25 | { 26 | import flash.net.NetGroup; 27 | } 28 | import flash.net.NetStream; 29 | 30 | import org.osmf.net.*; 31 | import org.osmf.player.configuration.PlayerConfiguration; 32 | import org.osmf.player.media.StrobeMediaPlayer; 33 | import org.osmf.traits.LoadTrait; 34 | import org.osmf.traits.MediaTraitType; 35 | 36 | public class MediaMetadata 37 | { 38 | public static const ID:String = "org.osmf.player.metadata.MediaMetadata"; 39 | 40 | public var mediaPlayer:StrobeMediaPlayer; 41 | public var resourceMetadata:ResourceMetadata = new ResourceMetadata(); 42 | 43 | } 44 | } -------------------------------------------------------------------------------- /src/org/osmf/player/metadata/ResourceMetadata.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | * 19 | **********************************************************/ 20 | 21 | package org.osmf.player.metadata 22 | { 23 | import org.osmf.net.DynamicStreamingItem; 24 | 25 | public dynamic class ResourceMetadata 26 | { 27 | // public var streamName:String; 28 | // public var streamItems:Vector.; 29 | } 30 | } -------------------------------------------------------------------------------- /src/org/osmf/player/utils/StrobeUtils.as: -------------------------------------------------------------------------------- 1 | /*********************************************************** 2 | * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved. 3 | * 4 | * ********************************************************* 5 | * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence 6 | * (the "License"); you may not use this file except in 7 | * compliance with the License. 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" 10 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing rights and limitations 12 | * under the License. 13 | * 14 | * 15 | * The Initial Developer of the Original Code is Adobe Systems Incorporated. 16 | * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems 17 | * Incorporated. All Rights Reserved. 18 | * 19 | **********************************************************/ 20 | 21 | package org.osmf.player.utils 22 | { 23 | /** 24 | * Utilities, unit converters, etc 25 | */ 26 | public class StrobeUtils 27 | { 28 | public static const KBITSPS_BYTESTPS_RATIO:uint = 128; 29 | 30 | public static function kbitsPerSecond2BytesPerSecond(value:Number):Number 31 | { 32 | return value * KBITSPS_BYTESTPS_RATIO; 33 | } 34 | 35 | public static function bytesPerSecond2kbitsPerSecond(value:Number):Number 36 | { 37 | return value / KBITSPS_BYTESTPS_RATIO; 38 | } 39 | 40 | public static function bytes2String(value:Number):String 41 | { 42 | if (isNaN(value) || value == 0) 43 | { 44 | return value.toString(); 45 | } 46 | 47 | var s:Array = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB']; 48 | var e:Number = Math.floor( Math.log( value ) / Math.log( 1024 ) ); 49 | return ( value / Math.pow( 1024, Math.floor( e ) ) ).toFixed( 2 ) + " " + s[e]; 50 | } 51 | 52 | public static function bytesPerSecond2String(value:Number):String 53 | { 54 | if (isNaN(value) || value == 0) 55 | { 56 | return value.toString(); 57 | } 58 | var bitsps:Number = value * 8; 59 | var s:Array = ['bits/s', 'kbit/s', 'Mbit/s', 'Gbit/s', 'Tbit/s', 'Pbit/s']; 60 | var e:Number = Math.floor( Math.log( bitsps ) / Math.log( 1000 ) ); 61 | return ( bitsps / Math.pow( 1000, Math.floor( e ) ) ).toFixed( 2 ) + " " + s[e]; 62 | } 63 | 64 | public static function bytesPerSecond2ByteString(value:Number):String 65 | { 66 | if (isNaN(value) || value == 0) 67 | { 68 | return value.toString(); 69 | } 70 | var bitsps:Number = value; 71 | var s:Array = ['Bytes/s', 'KB/s', 'MB/s', 'GB/s', 'TB/s', 'PB/s']; 72 | var e:Number = Math.floor( Math.log( bitsps ) / Math.log( 1024 ) ); 73 | return ( bitsps / Math.pow( 1024, Math.floor( e ) ) ).toFixed( 2 ) + " " + s[e]; 74 | } 75 | 76 | public static function retrieveHostNameFromUrl(url:String):String 77 | { 78 | var result:String = url; 79 | var startPosition:int = result.indexOf('://')+3; 80 | var endPosition:int = result.indexOf("/", startPosition); 81 | if (endPosition < 0) 82 | { 83 | endPosition = result.length; 84 | } 85 | result = result.substring(startPosition, endPosition); 86 | return result; 87 | } 88 | } 89 | } --------------------------------------------------------------------------------