Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Playback events are not triggered by media session API #37

Open
humbkr opened this issue Aug 6, 2020 · 6 comments
Open

Playback events are not triggered by media session API #37

humbkr opened this issue Aug 6, 2020 · 6 comments
Assignees
Labels
enhancement New feature or request

Comments

@humbkr
Copy link
Contributor

humbkr commented Aug 6, 2020

Describe the bug
Chrome and other browsers now ship with a feature to control media directly from the browser using the media session API:
https://developer.mozilla.org/en-US/docs/Web/API/Media_Session_API
https://techcrunch.com/2020/01/16/chrome-gets-global-media-controls

Problem: when using the Chrome media controls, the playback events like play, pause, ... are not triggered, ie isPlaying is not updated, resulting in an out of sync UI.

To Reproduce
Steps to reproduce the behavior:

  1. Using Chrome, start playing an audio file via an html button
  2. Use the browser media controls to pause the playback
  3. The audio is paused but the isPlaying variable is not updated

Expected behavior
The useAudioPlayer() state reflects the state of the audio playback.

Environment (please complete the following information):

  • Browser/ browser version: Chrome
  • Library version: 0.0.18
  • React version: 16.3.1
  • Node version: 10.15.0

Related issue: goldfire/howler.js#1262

@E-Kuerschner E-Kuerschner added this to To do in Project Roadmap via automation Apr 16, 2023
@E-Kuerschner E-Kuerschner added the enhancement New feature or request label Apr 16, 2023
@E-Kuerschner E-Kuerschner moved this from To do to In progress in Project Roadmap Apr 22, 2023
@E-Kuerschner E-Kuerschner moved this from In progress to To do in Project Roadmap Apr 26, 2023
@joeyiny
Copy link

joeyiny commented Jul 9, 2023

+1, lmk if I can help with this @E-Kuerschner

@E-Kuerschner
Copy link
Owner

E-Kuerschner commented Jul 10, 2023

@joeyiny I have something working locally! Hoping to get a release out this week cc @humbkr

@E-Kuerschner
Copy link
Owner

@joeyiny sorry for the delay! I still have a branch open for this but i ran into some difficulties with the global version of the hook. Will keep posting updates here

@joeyiny
Copy link

joeyiny commented Aug 10, 2023

@E-Kuerschner got it, let me know if i can help

@E-Kuerschner
Copy link
Owner

hey @joeyiny, @humbkr are you able to use the media session if you create the sound with html5 set to true?

const { load } = useAudioPlayer()

load({
  src: '/myFile.mp3',
  html5: true
})

After doing some research it appears that the media notification will only be set if an audio or video element is present on the page.

see: https://stackoverflow.com/questions/52226454/media-notifications-using-the-media-session-web-api-doesnt-work-with-web-audio

@E-Kuerschner
Copy link
Owner

pausing work on this for the time being since the Media Session Notification feature will not work with the Web Audio Api which is the default mode of operation for Howler. In order to integrate with the MediaSession the Howl needs to be created with the html5 option set to true.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

No branches or pull requests

3 participants