├── .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.