phiamo / capacitor-plugin-playlist

A capacitor migration of cordova-plugin-playlist
23 stars 20 forks source link

[iOS] Play after pause always resets to start of current track #9

Open dasantonym opened 3 years ago

dasantonym commented 3 years ago

Not sure if I am doing something fundamentally wrong here, but when I create a single-track playlist like this:

const player = new RmxAudioPlayer()
await player.initialize()
await player.setOptions({
  verbose: false,
  options: {
    icon: 'icon_bw'
  }
})
await player.addItem({
  title: 'asdf',
  assetUrl: uri,
  isStream: false,
  trackId: uuidv4()
})
await player.play()

This plays just fine, but pause seems to behave oddly.

When I call await player.pause() on the player, it pauses, but after calling await player.play() it always starts from the beginning of the track.

Seeking also has no effect and I am not getting any errors so I assume this is some fundamental problem here? The lock-screen controls cause the same reset after pause and then play. I tried it using the setPlaylistItems command and used the retainPosition: true option, but to no avail.

Edit: This is happening on iOS 13.1.2

dasantonym commented 3 years ago

Just saw that it behaves normally once I comment out this:

https://github.com/phiamo/capacitor-plugin-playlist/blob/8c671af58e73eaf7ffaa94e5f09c599d805b3ac0/ios/Plugin/AVBidirectionalQueuePlayer.swift#L185-L188