Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-12885

iOS - No sound after pause Media plugin ( sometimes )

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • cordova@7.0.0
    • None
    • cordova-plugin-media
    • iOS

    Description

      Media player will sometimes resume audio immediately. Seemingly randomly it will then have a delay after pause() then play() calls. The length of the delay seems to increase. Sometimes it goes straight to no audio sound at all. There is no indication from the error or status callback. The status indicates running. If I create a new Media instance it plays again.

      The stream is an infinite stream ( duration -1 )

      In searching the web I came across this discussion: https://github.com/delannoyk/AudioPlayer/issues/21

      which makes it sound like it could possibly be an issue on Apples side. What do you all think? For now I think I may resort to a new instance every time a pause/play is done since I cant seem to find any consistency in timing or any errors to react to.

      The code looks like:

      export default class MediaPlayer {
        constructor (station) {
          this.station = station
          this.status = window.Media.MEDIA_NONE
          this.audioPlayer = new window.Media(this.station.streamSource.file, () => {
            console.log('========> cordova audio: Success')
          }, (err) => {
            console.log('========> cordova audio: OnLoadError', err)
          }, (status) => {
            console.log('========> cordova audio: OnStatus', status)
            this.status = status
          })
        }
      
        get playing () {
          if (this.status === window.Media.MEDIA_RUNNING) {
            return true
          }
          return false
        }
      
        play () {
          if (!this.playing && this.audioPlayer) {
            this.audioPlayer.play()
          }
        }
      
        pause () {
          if (this.audioPlayer) {
            this.audioPlayer.pause()
          }
        }
      
        togglePause () {
          if (this.playing) {
            this.pause()
          }
          else {
            this.play()
          }
        }
      
        unload () {
          this.audioPlayer.release()
        }
      }
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            smakinson Shawn Makinson
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: