cordova-plugin-nativeaudio icon indicating copy to clipboard operation
cordova-plugin-nativeaudio copied to clipboard

How to play file:///data/data/com.ionicframework.testapp123/files/2887.mp3

Open ngrj opened this issue 7 years ago • 9 comments

Hi, I tried playing this file which I have downloaded using native file transfer plugin but it seems to append www/ in front to the url and it raises an exception called java.io.FileNotFoundException:

is there any flag which I need to add or is it not possible to play audio which is not inside www/ ?

ngrj avatar Apr 28 '17 08:04 ngrj

Same Issue here.

nlasso avatar Jul 22 '17 19:07 nlasso

Same issue.

filipecoimbra avatar Aug 09 '17 04:08 filipecoimbra

I had the same problem. After some research, I've decided that what we're trying to do is impossible. This plugin uses the AssetManager class to get access to audio files (see here in the source). The description of this class says explicitly:

This class presents a lower-level API that allows you to open and read raw files that have been bundled with the application...

So, basically, you can't play an audio file that has been downloaded by the app itself since it can't be retroactively bundled into the APK.

Instead, use the Media plugin. Here's an example.

morphatic avatar Sep 03 '17 21:09 morphatic

@morphatic I realised the same. Howerver, it is not a good option for me to use Media plugin since I need both a html5 video player and the audio to run at the same time. Only one can be running at a time :(

xixiaofinland avatar Oct 10 '17 05:10 xixiaofinland

@Xixiao007 are you sure? I am able to play more than one audio file at the same time using the Media plugin, so I'm thinking you should be able to play separate video and audio files at the same time. I don't have any examples, though, of how to do this.

morphatic avatar Oct 10 '17 16:10 morphatic

@morphatic Probably media plugin supports multiple audio playing in parallel. However, I need to play a video in html5 video. By given this, playing both html5 video and audio from Media plugin does not work. One will make the other stop :(

xixiaofinland avatar Oct 11 '17 13:10 xixiaofinland

Hi can you add a boolean to the preload method that leave the choice between absolute or relative path. if it is true the path is absolute then you don't add the www/ folder in the begin of path and if false the path is relative and you can add the cordova.file.applicationDirectory www/?

thank you

totovelo10 avatar Oct 22 '17 05:10 totovelo10

same issue here please help me.

sandeeppatel344 avatar Feb 22 '18 17:02 sandeeppatel344

user H5 audio

wenjianli92 avatar Dec 12 '18 08:12 wenjianli92