• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

Android Air - Access app files via native extension?

Guest
Jun 27, 2013 Jun 27, 2013

Copy link to clipboard

Copied

I've tried to use several video ANEs, they load video outside of the app fine, but if I try to provide a video that was packaged into the APK file they can't seem to access it. I have no experience developing native extensions or android apps, only AS3/AIR for android.

var localFile:File = File.applicationDirectory.resolvePath("video.mp4")

File.url traces "app:/video.mp4". The ANEs don't appear to be doing anything when given that path, searching the internet I found the path to the asset is in APK assets folder. And to use "file:///android_asset/video.mp4", this gets a response from the native media player via the ANEs but I get a dialog saying it was unable to play the video, the asset file name doesn't have to be a valid asset to trigger that dialog and the video asset itself does play on the device if I copy it over and play it out of the air app. I've read that the assets folder in the APK file can be compressed which is causing the problem.

I'm not sure how to approach this? Is it possible with AIR to have android access the APK's assets?

TOPICS
Air beta

Views

2.8K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 27, 2013 Jun 27, 2013

Copy link to clipboard

Copied

Indeed, a URL of the form app:/video.mp4 has no meaning outside your app.  But if you use localFile.nativePath, that should give you a fully qualified path name - i.e. /.../.../video.mp4

However, I'm not sure other apps will be allowed (for security purposes) to read that file, but at least that should be one step closer.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 30, 2013 Jun 30, 2013

Copy link to clipboard

Copied

nativePath doesn't work on Android, you will get a null returned.

I've had no luck providing an asset from the assets/ folder in the APK to androids native media player, however I was able to place the video file into res/raw/ folder in the APK, although you can't just unzip/place file/zip/sign, you have to decompile the app, add the file then compile and sign. I'm not sure if you can setup a build process to do this instead of the way ADT is doing it(FlashDevelop handles it with batch scripts). Doing this I was able to get the freshplanet ANE to play the video within my app, I was using a modified branch on github that added local playback support. The other ANE VideoManager didn't respond to this however. Would seem you need to copy the file to storage outside of the app/APK to make it more accessible.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jun 10, 2014 Jun 10, 2014

Copy link to clipboard

Copied

LATEST

Hi,

I've been investigating the issue trying to get access to video files packaged in an AIR app from an ANE but they are sometimes compressed in the APK rather than just being stored. Once they are compressed you get the following error:

java.io.FileNotFoundException: This file can not be opened as a file descriptor; it is probably compressed

I think this has to be an error in the AIR packaging, as they shouldn't be compressed. Any files like mp3, mp4, png etc shouldn't be compressed according to the Android packager.

air native extensions // https://airnativeextensions.com

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines