Do not set a duration for live streams
A live window with changing duration can't be properly displayed in a media notification. The duration constantly changes and creates a nervous jumping seekbar that is not really useful. This change sets the duration for live streams to `C.TIME_UNSET` when publishing the player state to the platform session. This way no duration is sent to the platform session which prevents media controls from drawing a seekbar. Issue: androidx/media#1256 PiperOrigin-RevId: 624112541
This commit is contained in:
parent
8ba44ad2b1
commit
fc1d60beb9
@ -19,6 +19,9 @@
|
||||
* Muxers:
|
||||
* IMA extension:
|
||||
* Session:
|
||||
* Hide seekbar in the media notification for live streams by not setting
|
||||
the duration into the platform session metadata
|
||||
([#1256](https://github.com/androidx/media/issues/1256)).
|
||||
* UI:
|
||||
* Downloads:
|
||||
* OkHttp Extension:
|
||||
|
@ -1292,7 +1292,10 @@ import org.checkerframework.checker.initialization.qual.Initialized;
|
||||
PlayerWrapper player = sessionImpl.getPlayerWrapper();
|
||||
@Nullable MediaItem currentMediaItem = player.getCurrentMediaItemWithCommandCheck();
|
||||
MediaMetadata newMediaMetadata = player.getMediaMetadataWithCommandCheck();
|
||||
long newDurationMs = player.getDurationWithCommandCheck();
|
||||
long newDurationMs =
|
||||
player.isCurrentMediaItemLiveWithCommandCheck()
|
||||
? C.TIME_UNSET
|
||||
: player.getDurationWithCommandCheck();
|
||||
String newMediaId =
|
||||
currentMediaItem != null ? currentMediaItem.mediaId : MediaItem.DEFAULT_MEDIA_ID;
|
||||
@Nullable
|
||||
|
@ -982,6 +982,10 @@ import java.util.List;
|
||||
return super.isCurrentMediaItemLive();
|
||||
}
|
||||
|
||||
public boolean isCurrentMediaItemLiveWithCommandCheck() {
|
||||
return isCommandAvailable(COMMAND_GET_CURRENT_MEDIA_ITEM) && isCurrentMediaItemLive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCurrentMediaItemSeekable() {
|
||||
verifyApplicationThread();
|
||||
|
Loading…
x
Reference in New Issue
Block a user