[ 
https://issues.apache.org/jira/browse/CB-14120?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16505728#comment-16505728
 ] 

Ken Naito commented on CB-14120:
--------------------------------

Hmm, perhaps this issue depends on mp3 file itself?

I tried to check following ionic codes, but I cannot reproduce this issue.

home.ts
{code}
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { Media, MediaObject } from '@ionic-native/media';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {

  private _mFile: MediaObject;
  private musicIndex: number;

  private musics = ["A.mp3","B.mp3","C.mp3"];

  constructor(public navCtrl: NavController, private media: Media) {
  }

  playAudioStart() {
    this.musicIndex = 0;
    this.playAudio();
  }

  playAudio() {

    this._mFile = this.media.create('assets/res/' + 
this.musics[this.musicIndex]);

    this._mFile.stop();
    this._mFile.play();

    this._mFile.onSuccess.subscribe(result => {
      this._mFile.release();
      this.musicIndex += 1;
      if (this.musicIndex < this.musics.length) {
        this.playAudio();
      } else {
        alert("Finished");
      }
    })
  }

}
{code}

home.html
{code}
  <div><button ion-button (click)="playAudioStart()">Primary 
Outline</button></div>
{code}

My environments are
ionic-cli 3.20.0
 cli-utils 1.19.2

 cordova (cordova-cli) 7.1.0
 @ionic/app-scripts: 3.1.9
 cordova platform: ios 4.5.4
 Ionic Framework (ionic-angular): 3.9.2

I have built project by both Xcode 9.4 and Xcode 9.3.1.
I have confirmed this on iPhone 5S/iOS 11.3.1 and iPhone 8/iOS 11.3.0

Could you please try the above code?

> Playback issues in iOS 11.3/11.4 
> ---------------------------------
>
>                 Key: CB-14120
>                 URL: https://issues.apache.org/jira/browse/CB-14120
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: cordova-plugin-media
>         Environment: Ionic 3, Angular JS 4
>            Reporter: Muddasir Lakhani
>            Priority: Blocker
>
> I am trying to play multiple audio tracks one after the other using the Media 
> Plugin.
> On pressing play, I download all the tracks as a zip file, and then play them 
> one after the other until the last track is played. This works fine on 
> Android (all models) and also on iOS up to 11.2. On iOS 11.3 onwards, the 
> next track never starts from the beginning, but from a random duration. So 
> basically if an Album has 4 tracks, first one will play from duration 00:00, 
> and then the next ones will start to play from random duration, and never 
> from 00:00.
> Code Snippet is below:
> {{if (ContainerClass.GetPlatformName() == "android") { this._mFile = 
> this.media.create(this._URL + "/" + AlbumNo + "/" + this._fileName[index]); } 
> else if (ContainerClass.GetPlatformName() == "ios") { this._mFile = 
> this.media.create((this._URL + "/" + AlbumNo + "/" + 
> this._fileName[index]).replace(/^file:\/\//, '')); } 
> this._mFile.onStatusUpdate.subscribe(status => console.log(status)); 
> this._mFile.stop(); this._mFile.play(); ServicesClass._mFile = this._mFile; 
> ServicesClass._isPlaying = 1; ServicesClass._playingAlbumNo = this.AlbumNo; 
> ServicesClass._isPlaying = 1 this._isPlaying = 1; 
> this._mFile.onSuccess.subscribe(result => { index++; this._playingIndex = 
> index; this._mFile.release(); if (ServicesClass._stopPlaying == false) { 
> this.PlayFiles(AlbumNo, index); this.showMp3Player(true); } else { return; } 
> }); this._mFile.onError.subscribe(error => console.log('Error!', 
> JSON.stringify(error))); } }}
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to