Ionic 4 - Error " MediaPlayer Error: Unknown (1) 0 " when using StreamingMedia

#1

Hi all!
i am new in ionic framewrok.i using StreamingMedia to play video, but when i run on real device then i got this error: MediaPlayer Error: Unknown (1) 0
-my code:
playVideo() {
const options: StreamingVideoOptions = {
errorCallback: function (e) {
console.log(‘ERROR play video: ’ + e);
},
successCallback: function () {
console.log(‘Success play video’);
},
orientation: ‘landscape’,
controls: true
};
this.stream.playVideo(’/assets/video.mp4’, options);
}

Please help me to fix the error!
Thanks.

#2

Have you tried to use ionic Native File to get the absolute path of your file like this.

 this._file.checkFile(this._file.applicationDirectory + 'www/assets/videos/', videoFile).then((correct: boolean) => {
    if (correct) {
      path = (this._file.applicationDirectory + 'www/assets/videos/' + videoFile);

      this.streamingMedia.playVideo(path, options);
    } else {
    
    }
  }).catch((err) => {
    
    console.log(err);
  });
1 Like
#3

Thanks lolaswift, let me try!