how to set a custom NetLoader for a f4melement in osmf

240 views Asked by At

I'm doing a custom osmf player using HDS with adaptive bitrate playing f4m content.

and I've been having some problems with the adaptive bitrate algorithm, it doesn't index a lower bitrate once that it reaches the highgest bitrate.

so I found that you cant configure some rules for the ABR algorithm using a custom NetLoader class... but until now I've found just examples using it over a videoelement.

I'm using the "mediaFactory.createMediaElement" method to obtain the mediaelement for a resource here is the code:

var resource2:URLResource = new URLResource(este);              
var element:MediaElement = mediaFactory.createMediaElement( resource2);
var videoelement:VideoElement= new VideoElement(new URLResource(este), new GoWebAB());
var sprite:MediaPlayerSprite= new MediaPlayerSprite();
//sprite.resource=resource2;
sprite.mediaPlayer.media=videoelement;
mediaPlayer=sprite.mediaPlayer;
//sprite.media=videoelement;            
addChild(sprite);               
1

There are 1 answers

0
arahaya On

You could create a MediaFactory instance and add your custom MediaFactoryItem like bellow

var mediaFactory:MediaFactory = new MediaFactory();
var loader:NetLoader = new GoWebAB();
mediaFactory.addItem 
    ( new MediaFactoryItem
        ( "org.osmf.elements.video"
        , loader.canHandleResource
        , function():MediaElement
            {
                return new VideoElement(null, loader);
            }
        )
    );

Look inside org.osmf.media.DefaultMediaFactory for more details of how to add a MediaFactoryItem.