Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70434

How to implement Background Mode for Cordova Media Plugin Playlist on IOS

$
0
0

@kendam wrote:

I have successfully implement a playlist feature for a Cordova Media plugin (https://github.com/apache/cordova-plugin-media) in my application .

However, on IOS, once the app screen is locked the current playlist item completes but it won’t move on to the next item .

I tried to use the cordova-plugin-background-mode but this didn’t solve my problem or I don’t know how to make it solve my issue.
Below is my code


ionViewDidLoad(){
    this.backgroundMode.enable();
  }
PlayAllList(i, tracks: AudioFile[],surah) {
   
    var self = this;
  
    let fileDir = "";
    if(this.plt.is('android')){
      fileDir = this.file.externalDataDirectory
     }
     else{
       fileDir = this.file.documentsDirectory.substr(7)
     }
    this.Audiofile = this.media.create(fileDir + tracks[i].trackUrl);
   
    this.Audiofile.play({playAudioWhenScreenIsLocked:true})
   
    this.Audiofile.onSuccess.subscribe(() => {
      if ((i + 1) == tracks.length) {
       this.Notplaying = true;
        this.Audiofile.release(); 
      this.Audiofile = undefined;
  
      } else {
       
      
        this.Audiofile.release()
      
        self.PlayAllList(i + 1, tracks,surah)
      }

    })
  
  }

I have been on this for days. any suggestion will be appreciated

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70434

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>