Questions tagged [mediasession]

The Media Session API enables web developers to show customized media metadata and controls on platform UI, such as in notification areas and on lock screens of mobile devices.

The Media Session API enables web developers to show customized media metadata on platform UI, customize available platform media controls, and access platform media keys such as hardware keys found on keyboards, headsets, remote controls, and software keys found in notification areas and on lock screens of mobile devices.

This API was introduced in Chrome for Android 45 in the year 2015.

References:

53 questions
12
votes
1 answer

MediaBrowserService with ExoPlayer and PlayerControlView - How to access to the player instance from the UI (PlayerControlView)?

I am currently working on a part of an app which has video and audio functionality, and started refactor the code base recently. The goal is to integrate MediaSession/ MediaController and MediaBrowserService/ MediaBrowser framework. We use ExoPlayer…
8
votes
1 answer

How to customize Global Media Controls in Google Chrome (question and answer)

How to Enable or Disable Global Media Controls in Google Chrome see "Global Media Controls" Go to chrome://flags/#global-media-controls Set "Enabled" Click button "Relaunch" How to customize (bacground image, action on click) Global Media Controls…
7
votes
1 answer

How to get rid of "media playing" notification shown by Chrome on Android?

My HTML5 game has some background music that uses Howler.js in "html5" mode, which apparently triggers Chrome for Android's media playback notifications. This means a notification appears while the user has my game open in any tab: The game is a…
Thomas
  • 174,939
  • 50
  • 355
  • 478
5
votes
0 answers

Android MediaSession: How to choose the icons shown on lock screen?

I have an app that plays media via MediaSessionCompat. I create a notification for the Notification Drawer using NotificationCompat and post it using NotificationManagerCompat.notify, and it looks great. (See screenshot.) My problem is with the lock…
Brian Rak
  • 4,912
  • 6
  • 34
  • 44
4
votes
0 answers

How to implement media session to support Google assistant

We are trying to implement media session in our video Android TV App to support Google Assistant voice control. On emulator, we can successfully send play, pause, fast-forward command to control Youtube playback, but when we try the official…
handhand
  • 736
  • 7
  • 12
4
votes
1 answer

How do I return the user to my TWA when pressing on a media notification?

I'm building an Android app that wraps my Progressive Web App as a Trusted Web Activity. (I'm following guidelines from Google's sample project.) When the user plays audio in the app, a media notification appears on the device. I'm using the web…
3
votes
0 answers

Starting up the media2 MediaSessionService causing some random crashes (using MediaController and ExoPlayer)

I've got some strange crashes on Firebase (and I was unable to reproduce them), that occur at the launch of my MediaSessionService : Fatal Exception: android.app.ForegroundServiceDidNotStartInTimeException Context.startForegroundService() did not…
3
votes
2 answers

Attempt to invoke interface method 'android.media.session.ISessionController android.media.session.ISession.getController()' on a null object

Below code is for music notification player with controls using media session.Whenever I click controls from notification it crashes with error mentioned above. Please see the code below and correct me if I am wrong.In below code I have used media…
3
votes
0 answers

mediaSession does not work with streaming

I have mediaSession working great when it comes to simple video files. You can use your media keys pause and play. let video = useRef(null) useEffect(() => { video.current.play() .then(_ => { navigator.mediaSession.metadata = new…
PepperAddict
  • 888
  • 2
  • 10
  • 16
3
votes
2 answers

Detect if

When playing a live audio stream, like web radio, through
kubi
  • 829
  • 2
  • 14
  • 24
2
votes
0 answers

Media Session API on iOS 16, does it require name/URL of website?

I'm playing around with a PWA web app created in Vue and I've added this as a Home Screen bookmark to my iPhone running iOS 16. When I play an audio file in the app, I create a Media Session instance that looks like this: if ("mediaSession" in…
tobiasg
  • 983
  • 4
  • 17
  • 35
2
votes
1 answer

MediaButtonReceiver.buildMediaButtonPendingIntent() Giving Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or

I made an audio application that shows a foreground notification in the notification tray with play/pause controls. It was working fine but after Android S started to get the "Targeting S+ (version 31 and above) requires..." error. Here is the…
Saif
  • 397
  • 1
  • 9
2
votes
1 answer

web audio player - iOS next song & previous song buttons are not in control center

This is something I've researched off and on for literal years and have never been able to find the answer. I found the MediaSession api which works for populating song data but the next track and previous track action handlers don't make the next/…
b.stevens.photo
  • 876
  • 2
  • 9
  • 18
2
votes
1 answer

MediaSessionCompat behaviour changed in Android 12 and setPlaybackToRemote stopped working properly

Prior to Android 12, I used code below to detect physical volume buttons pressed to show my custom UI, but it stopped working on Android 12 devices and onAdjustVolume is never called when I press volume buttons: mediaSessionCompat =…
AVEbrahimi
  • 17,993
  • 23
  • 107
  • 210
2
votes
0 answers

Get browser's active MediaSession data via extension API

Using a Chrome extension, I'd like to log the metadata from media played in the browser from pages that use the MediaSession API. Is it possible to get the current active MediaSession? If not, is it possible to get the MediaSession for a particular…
Brad
  • 159,648
  • 54
  • 349
  • 530
1
2 3 4