Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
12 Views

IOS: Play mp3 from application Directory

Hi,

next point next problem: On Android, it works, and IOS kills my serves.

var source = cordova.file.applicationDirectory + "/www/static/" +
                            slide.audio;
var player new Media(source, 

            function () {

            },
            function (e) {
                console.log(e);
                if (ios.isIOS()) {
                    alert(JSON.stringify(e));
                }
            },

);

player.play();

 

I always get Code 1, cannot use resource.

I already left out  cordova.file.applicationDirectory, and the "www"  part.
Additionally, I used 
resolveLocalFileSystemURL and toInternalURL, and toUrl() without a change.

If i use this with the application directory,

                        var success = function (e) {
                            console.log("LIST");
                            console.log(e);
                            if (e.isDirectory) {
                                rf(e.nativeURL());
                            }
                        }
                        var fail = function (e) {
                            console.log("FAILURE READING");
                            console.log(e);
                        }
                        var rf = function (ds) {
                            window.resolveLocalFileSystemURL(ds, function (dirEntry) {
                                var directoryReader = dirEntry.createReader();
                                console.log(dirEntry);

                                // Get a list of all the entries in the directory
                                directoryReader.readEntries(success, fail);
                            });
                        }

I only get 2 files, CDVNotification.bundle (file:///var/containers/Bundle/Application/0A527AB4-BEAD-478B-A367-98D541D74E12/Storyspot.app/CDVNotification.bundle/) as folder, and, Default-568h@2x~iphone.png as file.

What do I do wrong?

 

King regards,

Sascha

Tags (2)
0 Kudos
1 Reply
Highlighted
12 Views

Sascha -- check out the "hello cordova" sample app. It is able to play a media file from within your application directories. Look for the "btnBarkCordova()" function inside the "app.js" file.

0 Kudos