Question

My priority is to have a fullscreen (standard size) 1024x768 H264 video played on an ipad app compiled with flash CS5.5 AIR for iOS using the StageWebView class. This works perfectly fine. Although with no official way to communicate with the StageWebView, I can't 'remove' the video once it's done playing. Enter StageWebViewBridge which enables AS <=> JS communication.

I'm trying to get around the overall poor performance of the Video class on the iPad (1 or 2). Playing the video inside a StageWebView loading a html5 object works amazingly great (read: GPU hardware decoded h264).

I do need to shut the video off after it's done playing in the StageWebView. I am packaging a .mov file encoded in H264 that plays great in webkit browsers. If I just load a webpage in the StageWebView with a tag pointing to any video file it plays perfectly fine.

Once I introduce StageWebViewBridge it changes. They want files put in a /html folder. I'm sending paths of all kinds for the players src to play and no video ever loads. The video is named 'a.mov'. I tried player.src = 'a.mov', or player.src = 'html/a.mov', or player.src = './html/a.mov' or even using the File class to get the File.applicationDirectory and resolve the file to the .nativePath. No matter what I send from AS to the JS in the StageWebView page, I cannot get it to load the video.

Has anyone figured out how to reference embedded files? I'd like to send the file to load from AS to JS and have JS reset the .src property of a html5 element.

Even the File.applicationDirectory reference I make states the file 'exists', but I can never set the .src property of the element on the page. It doesn't seem to understand.

Any tips would be greatly appreciated.

No correct solution

OTHER TIPS

I am the maker of stagewebview bridge...

All of the things you comment, can be done with my class.... the way of reference a file in the html is:

<img src="appfile:/yourfile.jpg">

But I imagine the problem for you is that you will change the src dinamically and you don't know how to get the realpath for the file.

Just today I have updated my library... ( some bugs, and android version!!!)

I need to have time to upload the examples, but for an starting point look at the wiki and at this function from the javascript:

StageWebViewBridge.getFilePath( path )

Imagine you have a file inside the www dir ( yes that have changed and now is the root dir ) named video.mp4, and you need to assign the src of the video with jQuery...

Simply do this in JS:

$('#video').attr('src', StageWebViewBridge.getFilePath('jsfile:/video.mp4') );

Before doing nothig re-read the docs as it has been changed...

Say me if that helps....

I'm not sure I totally understand your question. A few things that may help:

  1. StageWebView does not understand the app:/ or app-storage:/ protocols that are used elsewhere in AIR. So make sure the URLs you are using file:/ if using a local video file. I'm not as familiar with iOS, but if you can't access files in app-storage or app (assuming you're trying to do that) you can possibly copy them over to File.userDirectory (which on Android is the SD card) on app startup.

  2. Perhaps you don't need the full StageWebViewBridge? I've written up the basics of how to do AS to JS communication (and vice-versa) with StageWebView on my blog. It sounds like for your needs, you only need AS -> JS, which simply means doing a swv.loadURL("javascript:somefunction('videoURL')"). Where somefunction sets the src parameter of your HTML5 tag.

For easier communication between your Air app and JavaScript, you may try this ANE we have built https://github.com/myflashlab/webView-ANE

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top