1 person found this helpful
OVP uses a shared object to store the average max bitrate last used. You could do the same in your player or use some arbitrary selection method such as "use the index with the highest bitrate less than or equal to 600kbps".
To do this in OSMF you need to set the initialIndex property on the DynamicStreamingResource for the MediaElement.
The Akamai plugin for OSMF doesn't select a starting index for dynamic streaming so using that plugin won't help you in this case. That logic probably belongs at the player level anyway.
Since you are using the SMIL plugin, you are probably calling createMediaElement on a MediaFactory and therefore this may not be trivial since you'll have to get to the DynamicStreamingResource before the NetStreamPlayTrait calls the NetStream.play2() method.
Can you file a bug on this? Specifically about making this easier to do using the SMIL plugin, perhaps using resource metadata.
Charles, thanks for your help. However, i still don't understand how this is supposed to work.
Yes, i am using the createMediaElement()with the MediaFactory. I am passing a .smil url as the host so i have no idea how many streams are in there. And i am only getting the total number of streams and any other stream information after the stream starts playing (when i am getting the DynamicStreamTrait).
So how i am supposed to set the initialIndex before the stream plays ?
I think you have a few options:
You could modify the SMIL plugin to take a resource metadata value specifying the start index and change the logic that creates the DynamicStreamingResource to use this value to set the initialIndex. Then file a bug for us to make this change or a better one to make this easy for people to do this using the SMIL plugin.
Or you could write your own SMIL parser and create the DynamicStreamingResource object yourself. Inspecting the bitrates in the object and choosing a starting index either based on the avg max bitrate you've saved in a shared object or some other bitrate selection process. Parsing the SMIL for FMS MBR should be trivial. There is a very simple parser in OVP you could take a look at.
Here a description of the workflow that we used for making the player start with higher initial index(based on the measured bandwidth) in StrobeMediaPlayer.
1. Initially we disable automatic switching (otherwise you cannot change the starting index manually):
private function onIsDynamicStreamChange(event:Event):void
this.autoDynamicStreamSwitch = false;
2. In our NetLoader we override the createNetStreamSwitchManager method and the set the initial index based on the badwidth measurements we stored in LSO:
override protected function createNetStreamSwitchManager(connection:NetConnection, netStream:NetStream, dsResource:DynamicStreamingResource):NetStreamSwitchManagerBase
dsResource.initialIndex = initialIndex;
3. In the end we turn automatic switching back to true:
private function onMediaPlayerStateChange(event:MediaPlayerStateChangeEvent):void
if (event.state == MediaPlayerState.PLAYING)
if (isDynamicStream && autoDynamicStreamSwitch != autoSwitchQuality)
autoDynamicStreamSwitch = autoSwitchQuality;
For doing this in a plugin you'll need to use the DynamicStreamTrait (you can set the autoSwitch property to true/false from your plugin.
Here are some links that I hope will be helpful to you:
1. See the StrobeMediaPlayback in action here:
(observe the lsoDownloadKbps which is your bandwidth that we store in a local SharedObject and observe the dynamic stream info. The first time you load the page your player will start with the 0 index. Later it should start the player with the most appropriate index for you.)
2. Take a look at our implementation
Hope this helps,
Thanks guys, now it starts to make sense ...
However, i still don't get the main part (sorry for being stupid )
How do i get the NetStream and NetConnection if i use the mediaFactory to create my media elements ?
_currentMediaElement = mediaFactory.createMediaElement(urlResource);
I understand that i could subclass the NetLoader if i would go like
_currentMediaElement = new VideoElement(urlResource, myNetLoader);
but i would love to use the factory and just let it decide how to build stuff.
Thank you for your patience with me
The recommended way to get the NetStream/NetConnection is by overriding the NetLoader (http://forums.adobe.com/message/3028789).
Is it a player or a plugin that you are working on? Can you provide more details about your usecase?
The thread you are referring to is also started by me and i still have no idea how to accomplish this
It is a player that plays all kind of streams (live, vod, progressive and dynamic), that's why i would love to just use the mediaFactory to let it care about media types, .smil files for dynamic streams etc. As far as i understand all Netconnections, netloaders etc are created internally and there is no real way to access them ?
Is there a way to overwrite and use my own netloaders with my approach of using the factory ?
It looks like I experience exactly the same challenges when working on the StrobeMediaPlayback that you are trying to overcome. I wish it was easier to get the NetConnection and NetLoader and the Resource created by the F4M or SMIL loaders, and I also hope this becomes easier in a future OSMF version.
I created my own custom MediaFactory *https://sourceforge.net/adobe/smp/svn/LATEST/tree/trunk/player/StrobeMediaPlayback/src/org /osmf/player/media/StrobeMediaFactory.as) and I replaced the loaders for both RTMP and HTTP dynamic streaming with my custom loaders.
Try browsing the source of the StrobeMediaPlayback to see how I use it there: https://sourceforge.net/adobe/smp/svn/LATEST/tree/trunk/player/StrobeMediaPlayback/src/
While you look at the code, you might also review it and provide some improvement feedback
Akamai has a new plugin that handles everything you can do on the Akamai network, including setting the starting bitrate or starting index for dynamic streaming content. Contact your Akamai sales rep or customer care for info on how to get the plugin. This should make your life much easier.