Archive

Archive for September, 2011

Determining playback bitrate in an OSMF video player

September 21st, 2011 No comments

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.

Categories: Flash development Tags:

Linking to local files in StageWebView

September 20th, 2011 4 comments

I have been working with StageWebView in a Flex Mobile AIR project recently. StageWebView uses the native web view on whatever device the AIR app is running. This means the text scrolling is very responsive and you inherit a bunch of functionality that an AS3 based component does not offer. For example, on Android you get pinch zoom and auto text-reflow. I need the text to have simple formatting which includes hyperlinks that link to other “pages”. It just so happens that storing the files in individual html files and loading them into a StageWebView instance solves this use case nicely.

It’s not so simple though. A hyperlink touch fails to load the local page since the StageWebView tries to go out to the web to load the URL supplied by the anchor tag. I found the solution was to hijack the page load on the LocationChangeEvent.LOCATION_CHANGING event and replace it with content loaded from the local html file using an URLLoader. You can see my code example here: http://github.com/randytroppmann/StageWebView—linking-local-files/blob/master/src/GreyRectangleStageWebViewBug.as.

Categories: Flash development Tags: