Cordova Media Thread Warning


#1

I’m using ionic framework to develop a song player application on iOS.
I use cordova media plugin to play music.
The user can listen to music online, or he/she can download the music to filesystem and listen to it locally.
So I have to check file existence and then play the music.
For some songs the player plays correctly, but whenever the app has “Thread Warning” the song does not play.

$cordovaFile.checkFile(cordova.file.documentsDirectory, "song-" + songId)
    .then(function () {
        var source = cordova.file.documentsDirectory + "song-" + songId;
        source = source.replace('file://','');
        $scope.media = new Media(source);
        $scope.media.play();
    }, function() {
        var source = "mydomain.com/song/" + songId;
        $scope.media = new Media(source);
        $scope.media.play();
    }
);

The warning is: THREAD WARNING: [‘Media’] took ‘12.166992’ ms. Plugin should use a background thread.