Skip to main content
WilliamACollins
Participating Frequently
December 8, 2011
Question

Android, StageWebView and Local media files in mobile app

  • December 8, 2011
  • 4 replies
  • 8604 views

Hi,

I am building a cross-platform mobile app with Flash Builder 4.6 (for iOS and Android). The app needs to have several hundred Mbs of video packaged with the app so that they run quickly and beautifully, with the native player controls. I ued an instance of StageWebView and loaded a local URL using nativePath and URL, which worked a treat on iOS. When testing on a Motorola Xoom, I get nothing. I can use the SWV instance to load up a remote file (ie Google.com) and it works fine on the Android device, but no local files. I understand that Android doesn't like the app URI, so I have changed from nativePath to the URL string, and still nothing. I have tried loading a local HTML file which embeds the necessary video in it, and no dice; the html page loads fine, but can't load the video.

Here's some code:

webView = new StageWebView;

webView.stage = this.stage;

webView.viewPort = new Rectangle(200,200,480,360);

var fPath:File = File.applicationDirectory.resolvePath("/assets/absMovie.html");

trace("fpath = "+fPath.nativePath);

var fPath2:String = fPath.url;

webView.loadURL(fPath2);

trace("fPath2 = "+fPath2);

Here is my console after running:

fpath = /assets/absMovie.html

fPath2 = file:///assets/absMovie.html

Error #2044: Unhandled ErrorEvent:. text=[-1] The Web page contains an error.: file:///assets/absMovie.html

I have been banging my head against this particular wall for over a week now, and I need to figure this out.

Any help would be appreciated.

Kindest Regards,

William

This topic has been closed for replies.

4 replies

Inspiring
December 17, 2011

Hi,

As far I know, is really imposible to get the correct path to a Android file in the applicationDirtectory.

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/filesystem/File.html

"On Android, the nativePath property of a File object pointing to the application directory is an empty string. Use the url property to access application files."

The only workarround is to move/copy the file to the applicationStorageDirectory and load then this file in the webview

You can use my StageWebViewBridge class to access the "easy way" resources in a StageWebView and do communication between JS&AS3...

http://code.google.com/p/stagewebviewbridge/

WilliamACollins
Participating Frequently
December 19, 2011

Hi, x. I contacted you a week or so ago about this and you asked for more error information. I forwarded that to you and haven't heard back yet. Thanks for checking in with me.

Regards,

William

Inspiring
December 20, 2011

Hi,

Sorry I complete missed the mail ;-(...

I have not too much time now to see what is your problem, the lines containig the error "seems" to be a problem with the location of files... I think you ar not "including" "packaging" the contens of the www dir into the final project...

Anyway, some time ago I was make an flex project to test... I don't know if it works now...( I must install FB4.6 .... normally I use FDT )...

You can find it here... in the fixed issues section

http://code.google.com/p/stagewebviewbridge/issues/detail?id=9&can=1

Say me if it helps....

El 19/12/2011, a las 23:13, WilliamACollins escribió:

Re: Android, StageWebView and Local media files in mobile app

created by WilliamACollins in Mobile Development - View the full discussion

Hi, x. I contacted you a week or so ago about this and you asked for more error information. I forwarded that to you and haven't heard back yet. Thanks for checking in with me.

Regards,

William

Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page:

To unsubscribe from this thread, please visit the message page at . In the Actions box on the right, click the Stop Email Notifications link.

Start a new discussion in Mobile Development by email or at Adobe Forums

For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

Participating Frequently
December 17, 2011

I've been having trouble with this to, it's in my list of stuff to research.  

I think this has something to do with the setting that Android uses to install the application.  If it is set to AUTO, android installs it where ever it thinks it has space.... so in the aftermath of installation referencing the app folder.... Android is getting confused.

try setting theconfig for Android to save applications to the SD CARD.  then try it.... the try and Save apps to the Device, then try it.

darkriderdesign

Participant
December 15, 2011

Hi WillaimACollins, just wondering if you ever got this working.

Been trying for the last week to get this working and also have been unable. Found out how to direct it to the installed video's but they're just not showing up.

Also stagewebview isn't closing when i move around the app. Like you, I have it working fine on iOS so don't know why it's not working on Android.

var newVid:StageWebView = new StageWebView();

newVid.stage = this.stage;

newVid.viewPort = new Rectangle(41, 132, 982, 540);

    

var f:File = File.applicationDirectory.resolvePath("video/video.mp4");

var f2:File = File.createTempDirectory();

f.copyTo(f2.resolvePath("video.mp4"),true);

newVid.loadURL(f2.url + File.separator +"video.mp4");

Did you ever figure this out? Netstream just seems to lag after awhile.

WilliamACollins
Participating Frequently
December 16, 2011

I am using a similar approach as your code, and I am getting similarly unacceptable results. I haven't been able to fix this yet.

WilliamACollins
Participating Frequently
December 13, 2011

bump...Maybe I shouldn't have posted so close to the weekend!

-William

Colin Holgate
Inspiring
December 13, 2011

It's always best to post messages at least four days away from the nearest weekend.

Also, try to get your question down to as few lines of text as possible. I STILL didn't fully read your question!

One thing to note, some app stores have a 50MB limit as to how big your app can be. You might think about your whole idea.

By the way, on Android you can play native H.264 video using netstream.

WilliamACollins
Participating Frequently
December 13, 2011

Thanks for the reply, Coliln.

By being verbose, I was trying to precursor the usual answers I've seen to such queries, like "Just stream the videos", etc.

Also, this will be an enterprise app, downloaded from our own servers, so the size won't be limited (as to whether users want to download such a big file, well, that's not up to me:) ).

In regards to using netStream, I have been looking into it, but it still seems that there is some sort of sandboxing issue that is precluding me from using the native browser to view the files in the app directory. I know that I coudl conceivably copy the videos to the appStorageDirectory and then access them there, but copying so many files seems like a waste of already limited space.

Again, thanks so much for taking the time to respond.

Kindest Regards,

William