Can't get $cordovaMedia to stream url

I am having a real issue getting $cordovaMedia to work on IOS. I have the plugin installed.

Here is my controller:

.controller(‘MediaCtrl’, function($scope, $state, $cordovaMedia,$ionicLoading) {

var src = “http://releases.flowplayer.org/data/fake_empire.mp3”;

var media = $cordovaMedia.newMedia(src).then(function() {
// success
}, function () {
// error

});

var iOSPlayOptions = {
numberOfLoops: 2,
playAudioWhenScreenIsLocked : false
}

$scope.StartPlaying = function() {
media.play(iOSPlayOptions);
}

$scope.StopPlaying = function() {
media.stop();
}

})

here is my template

 <h1>Audio recorder</h1>
 <button ng-click="StartPlaying()">Play</button>
 <button ng-click="StopPlaying()">Stop</button>
no errors just no music any help would be appreciated.

Try the following changes (Note: I haven’t tested it, just working from memory from my last project where I used cordovaMedia):

.controller('MediaCtrl', function($scope, $state, $cordovaMedia,$ionicLoading) {

    var src = "http://releases.flowplayer.org/data/fake_empire.mp3";

    var media = new Media(src, function() {
        // success
    }, function () {
        // error
    });

    var iOSPlayOptions = {
        numberOfLoops: 2,
        playAudioWhenScreenIsLocked : false
    }

    $scope.StartPlaying = function() {
        media.play(iOSPlayOptions);
    }

    $scope.StopPlaying = function() {
        media.stop();
    }

})

Note that instead of $cordovaMedia.new(), try using new Media(). I believe the two forms work differently.

Thanks so much that worked. I really appreciate the assit I spent way too much time on this.

1 Like

I got this error whenever trying to create media object

Error: Media is not defined

how to solve this ?

Are you testing on device? The plugin needs to be run from device. It will give that error in browser

What are the stream formats this support? I can not find it.

Nota: I need to reproduce http://01.solumedia.com.ar:8330/;stream.nsv