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

Media plugin seems to conflict with youtube video playing on IOS 11+

$
0
0

@mosta2 wrote:

Hi,
I have an Ionic 2 app, that uses media plugin to record audio then play back using Audio, this works fine on android but not on ios 11 and 12:
Once the media plugin is used to record audio after that youtube cannot play a video inside the in-app browser (video loads but not playing)

the following is the code:

startrecord(){
try{
  this.filename = this.filename.replace(".wav",Number(new Date()).toString()+".wav");
  this.recordStatus =1;
  //IOS
  this.file.createFile(this.file.tempDirectory, this.filename, true).then(() => {
    this.file.checkFile(this.file.tempDirectory,this.filename).then(()=>{
    this.mfile  = this.media.create(this.file.tempDirectory.replace(/^file:\/\//, '') + this.filename);
    this.mfile.startRecord();
  },()=>{alert('File does not exist' + this.dir+this.filename);
  
});
  });

}catch(e){alert('error2:'+e);}
}

stoprecord(){
try{
  //
  this.mfile.stopRecord();
  this.mfile.release();
  this.recordStatus =2 ;
   this.file.checkFile(this.file.tempDirectory,this.filename).then(()=>{ //alert('exists');
    },()=>{
    this.file.resolveLocalFilesystemUrl(this.file.tempDirectory+this.filename)
    .then(r => {
      try{this.playback(r)}catch(e){console.log(JSON.stringify(e));}}
      )
    .catch(e => alert('error1:'+JSON.stringify(e)));
  
}catch(e){alert('error:'+ JSON.stringify(e));} 
}

playback(r){
      this.play(r.nativeURL.replace(/^file:\/\//, ''));
    }


play(url)
{
  
  this.myaudio = new Audio(url);
  var readyStateInterval = null;
  if(this.myaudio !=null && this.myaudio.paused)
      {
        this.myaudio.play();
        
        return;}
  readyStateInterval = setInterval(function(this){
      if (this.readyState <= 2) {
      this.playstatus=this.readyState;
      }
   },1000);
   
openlink(){
        const browser = this.iab.create('https://www.youtube.com/watch?v=C0DPdy98e4c','_blank');
      
  }
}

Ionic:

ionic (Ionic CLI) : 4.5.0 (C:\Users\admin\AppData\Roaming\npm\node_modules\ionic)
Ionic Framework : ionic-angular 3.9.2
@ionic/app-scripts : 3.1.5

Cordova:

cordova (Cordova CLI) : not installed
Cordova Platforms : android 6.3.0, browser 5.0.4, ios 4.5.4
Cordova Plugins : cordova-plugin-ionic-webview 1.1.1, (and 16 other plugins)

System:

NodeJS : v10.13.0 (C:\Program Files\nodejs\node.exe)
npm : 6.5.0
OS : Windows 10

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70435

Trending Articles



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