Determining playback bitrate in an OSMF video player
NAIT has been using my custom video player for years which has seen several updates and redevelopments over time. A year and a half ago I completely rebuilt the player using Adobe’s OSMF library and it has worked flawlessly. The recent release of OSFM 1.6 spurred me on to revisit the player to bring it up to date. A lot has changed in the last year and a half, the most significant item being StageVideo.
I was really happy to see that merely swapping out the OSMF.swc library and recompiling was all I needed to do. No errors. This alone made the work around incorporating OSMF worth it. The only consequence of this update is the minimum Flash Player version required is now 10.1.
One item I finally figured out was how to determine total bitrate during video playback. NetStream has a NetStreamInfo property (called info) which contains all sorts of juicy info, but OSMF does not have any public API for getting access to the NetStream instance. With a lot of googling I found that the not-documented MediaTraitType.LOAD trait has a reference to the NetStream object and can be accessed this way:
var mediaLoadTrait:Object = mediaPlayer.media.getTrait(MediaTraitType.LOAD); var netStreamInfo:NetStreamInfo = mediaLoadTrait.netStream.info;
NetStreamInfo has a property of playbackBytesPerSecond which is what I needed. We use this information for monitoring quality of service. Note that this is bytes per second and most people talk about bitrate as kilobits per second. According to google you need to multiply this number by 0.0078125 to determine the kbps bitrate.
