Skip to content
This repository has been archived by the owner on Oct 6, 2022. It is now read-only.

Unable to update duration (live stream use case) #390

Open
2 of 4 tasks
scottg489-tw opened this issue Jun 8, 2021 · 0 comments
Open
2 of 4 tasks

Unable to update duration (live stream use case) #390

scottg489-tw opened this issue Jun 8, 2021 · 0 comments

Comments

@scottg489-tw
Copy link

scottg489-tw commented Jun 8, 2021

Description

We have a live stream which has a dynamic duration. As the stream plays and we receive more stream data, the duration progresses forward and we would like to update the duration in the notification screen. However, MusicControl.updatePlayback does not seem to support supplying a duration.

We attempted to work around this by calling MusicControl.setNowPlaying with the new duration when the duration changes. However, on iPhone this causes the elapsed time to jump to 0 seconds briefly and then back to the correct elapsed time even though we call updatePlayback with the elapsed time right after. This somewhat makes sense because it doesn't seem like setNowPlaying should be used to do updates.

It would seem that to correct this issue MusicControl.updatePlayback needs to be updated to accept duration as a parameter. Is this correct or is there existing functionality that would support our use case?

Example code

componentDidUpdate(prevProps) {
  MediaControl.setNowPlaying({
    title: 'Some title',
    artist: 'Some artist',
    duration: this.props.duration,
  });
  MediaControl.updatePlayback({ elapsedTime: props.time });
}

We are calling setNowPlaying with the new duration which updates the duration to the appropriate time but also sets the elapsed time to 0. We then immediately call updatePlayback to update the elapsed time to the correct time. This seems hacky and likely not how the library should be used, and although it works on Android it unfortunately does not work on iPhone.

Platform

  • iOS
  • Android

Device

  • Simulator
  • Real device
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant