-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add notification controls (#3723)
* feat(ios): add `showNotificationControls` prop * feat(android): add `showNotificationControls` prop * add docs * feat!: add `metadata` property to srouce This is breaking change for iOS/tvOS as we are moving some properties, but I believe that this will more readable and more user friendly * chore(ios): remove UI blocking function * code review changes for android * update example * fix readme * fix typos * update docs * fix typo * chore: improve sample metadata notification * update codegen types * rename properties * update tvOS example * reset metadata on source change * update docs --------- Co-authored-by: Olivier Bouillet <freeboub@gmail.com>
- Loading branch information
1 parent
c59d00a
commit 8ad4be4
Showing
18 changed files
with
908 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
android/src/main/java/com/brentvatne/exoplayer/VideoPlaybackCallback.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.brentvatne.exoplayer | ||
|
||
import android.os.Bundle | ||
import androidx.media3.common.Player | ||
import androidx.media3.session.MediaSession | ||
import androidx.media3.session.SessionCommand | ||
import androidx.media3.session.SessionResult | ||
import com.google.common.util.concurrent.ListenableFuture | ||
|
||
class VideoPlaybackCallback(private val seekIntervalMS: Long) : MediaSession.Callback { | ||
override fun onConnect(session: MediaSession, controller: MediaSession.ControllerInfo): MediaSession.ConnectionResult { | ||
try { | ||
return MediaSession.ConnectionResult.AcceptedResultBuilder(session) | ||
.setAvailablePlayerCommands( | ||
MediaSession.ConnectionResult.DEFAULT_PLAYER_COMMANDS.buildUpon() | ||
.add(Player.COMMAND_SEEK_FORWARD) | ||
.add(Player.COMMAND_SEEK_BACK) | ||
.build() | ||
).setAvailableSessionCommands( | ||
MediaSession.ConnectionResult.DEFAULT_SESSION_COMMANDS.buildUpon() | ||
.add(SessionCommand(VideoPlaybackService.COMMAND_SEEK_FORWARD, Bundle.EMPTY)) | ||
.add(SessionCommand(VideoPlaybackService.COMMAND_SEEK_BACKWARD, Bundle.EMPTY)) | ||
.build() | ||
) | ||
.build() | ||
} catch (e: Exception) { | ||
return MediaSession.ConnectionResult.reject() | ||
} | ||
} | ||
|
||
override fun onCustomCommand( | ||
session: MediaSession, | ||
controller: MediaSession.ControllerInfo, | ||
customCommand: SessionCommand, | ||
args: Bundle | ||
): ListenableFuture<SessionResult> { | ||
when (customCommand.customAction) { | ||
VideoPlaybackService.COMMAND_SEEK_FORWARD -> session.player.seekTo(session.player.contentPosition + seekIntervalMS) | ||
VideoPlaybackService.COMMAND_SEEK_BACKWARD -> session.player.seekTo(session.player.contentPosition + seekIntervalMS) | ||
} | ||
return super.onCustomCommand(session, controller, customCommand, args) | ||
} | ||
} |
Oops, something went wrong.