I am using XDK for developing apps for android, iOS and Windows.
I need to play the audio file which is in the path "/asset/audio/opening_song.mp3".
I can use the path to evaluate on XDK which is on my Mac Air in Nexus 4, iphone 6, and Toshiba Satlelite Ultrabook simulation,
and also can build for android successfully.
But when I try to use App preview on iPhone6 and windows 10, it can not load the music, and it seems the path is not right under ios and windows.
What will be the real location of the audio file on ios and Windows? Please help.
Thank you very much.
I recommended that you place the directory that you mentioned above under the www/ directory.
For more information about using the Cordova* Media plugin especially accessing the audio file appropriately, visit https://www.npmjs.com/package/cordova-plugin-media.
If you are using HTML5 audio features, you should be able to access the audio file by referencing the relative directory path from the file that executes the function.
Please see how it is done in the hello cordova demo app, in the app.js file you'll find a "bark" function that figures out how to reference the file as a function of the system, using some utilities also provided in that sample called webroot and webpath. There are lots of comments and console.log messages in that sample (if you enable the console.log messages, see the comments in the app.js file).
Thank you so much for your reply.
In fact, I found this problem first from the HelloCordova demo.
If you test it on iPhone 6 App Preview, the BarkCordova is not work too.
But interesting part is it works fine on BarkHTML5 and EMULATE of XDK.
I am wondering if it cause by the iOS 8 change the directory from file://var to file://private/var and www/directory problem.
The reference is as below:
But I tried every combination I can guess, it is still not work.
I already move all my file under www directory and it works fine both on android and windows, but still not work on iOS.
and the new path on my source is "www/asset/audio/opening_song.mp3".
So I suggest to revise some code of HelloCordova Demo to make it work fine on ios app preview and build.
And please give me the right path of my audio files on ios app preview, for work out this problem.
Thank you so much for your help.
By the way, after I tried HelloCordova on Windows 10,
I found is not work on App Preview on Windows 10,
It shows "Waiting for windows.cordova..."
If I build it and run on windows 10, the BarkCordova will Bark one time then the Application down.
So may be even the codes of HelloCordova for windows have to revise.
For your reference.
Hi Matrix -- we suspect there is a permissions problem or a plugin problem for he media play on iOS -- it was working properly before iOS 9, and does work on some iOS 9 devices. I've already tried some of the variations in the file paths. There is a Cordova Jira that has already been posted by some Cordova developers. You might want to look into some third-party plugins to play that back, or just use the HTML5 technique on iOS devices. Most of the Windows 10 code won't work until you build it with our upcoming CLI 5.4.1 build system.
I will wait and expect the new HelloCordova Demo and CLI 5.4.1.
But if that is possible, I still want to know the path of media file under App Preview of iOS.
Thank you so much for your help.
See how the webPath and webRoot functions are used in the Hello, Cordova app to get the real path. Enable the console logs and you'll see what they do when you run the bark buttons. The source to those functions is provided in the util.js file.
webPath and webRoot seems return the wrong path. (no file://private or something missing)
That is may be why even HelloCordova's BarkCordova not work in App Preview of iOS.
They are returning the correct path. What you see will depend on whether you are executing it in the Emulate tab, in App Preview, in the Debug tab or in a built app (as well as on an Android device, an iOS device, etc.). They'll all be different due to the way those different environments sandbox your app. Those functions are telling the truth. Note that those functions are returning the path to your index.html file, from there you have to modify the results by removing index.html from the returned path and appending the relative path to your specific file of interest (that is, relative to the location of your index.html file), just as the bark function inside Hello, Cordova is doing.
Matrix -- the functions are returning the proper paths, but as I stated in an earlier post (https://software.intel.com/en-us/forums/intel-xdk/topic/621257#comment-1864797) there is a known bug that we not resolved. Something changed in a recent update to iOS 9 that is causing this problem, we do not yet know what the reason for the problem is. The only workaround at this time would be to use the HTML5 technique, which does work, or locate an alternate plugin for playing back the audio.
Dear Paul and Elroy,
Hope the known bug will fixed ASAP.
By the way,
the XDK Server is down now, and can not build.
and https://appcenter.html5tools-software.intel.com is down also.
Is that possible to notice someone fix this serious situation as soon as possible.
I need to build a new version app for tomorrow's demo.
Thank you very much.
That's because simulator establishes document root from the project folder and NOT the source dir like www or diy (OpenShift's) like in my case. So you will have somewhat of http://localhost:SOME-4DIGIT-PORT/www/index.html
People just dont know what IDE they are building.