In Part 1 we briefly looked at some documentation and references for quickly getting up to speed on OSMF. Now in Part 2 I want to touch on some different options the developer has regarding what classes to use to actually build their OSMF video player. The main difference in the various options has to do with choosing ease of coding and simplicity versus flexibility / player capabilities. One option is to use the VideoElement class. Video element makes it simple to connect to a video stream and instantiate a player:
var mediaPlayerSprite:MediaPlayerSprite = new MediaPlayerSprite();
var videoElement:VideoElement = new VideoElement();
var dynResource:DynamicStreamingResource = new DynamicStreamingResource("rtmp://cp67126.edgefcs.net/ondemand");
dynResource.streamItems = Vector.<DynamicStreamingItem>([]); //code shortened here; see the documentation for the full example
videoElement.resource = dynResource;
addChild(mediaPlayerSprite);
mediaPlayerSprite.media = videoElement;
The benefit of using VideoElement is it’s simple to instantiate, however it is also limited in that it can’t handle all types of media, such as a swf or a dynamic multi-bitrate stream. So, if you know exactly what media types your player is going to be handling, then VideoElement may be sufficient for your needs. But if you need your player to be a little smarter, and handle any type of media “automagically”, then you should look into abstracting your code a little more, such as by using DefaultMediaFactory (see the ASDOC for code example). DefaultMediaFactory will add a layer of abstraction, allowing your player to add the appropriate org.osmf.elements class depending on the media stream it receives, e.g. VideoElement vs. SWFElement vs. F4MElement, etc.
Leave a Reply