Class VideoPlayerUtilsKt
-
- All Implemented Interfaces:
public final class VideoPlayerUtilsKt
-
-
Method Summary
Modifier and Type Method Description final static BooleanshouldPlayVideo(Context $self, Boolean isLockScreen)Determines whether video playback should be allowed based on device state. final static MediaPlayergetMediaPlayerInstance(Context context)Creates a MediaPlayer instance appropriate for the current Android version. final static UnitsetAudioFocusParams(MediaPlayer $self, AudioFocusManager audioFocusManager)Sets audio focus parameters on the MediaPlayer based on Android version. -
-
Method Detail
-
shouldPlayVideo
final static Boolean shouldPlayVideo(Context $self, Boolean isLockScreen)
Determines whether video playback should be allowed based on device state.
This function checks the device's power state and lock screen status to determine if video playback should proceed. It considers whether the screen is on/interactive and whether lock screen playback is enabled.
- Parameters:
isLockScreen- Whether lock screen video playback is enabled- Returns:
true if video should play, false otherwise
-
getMediaPlayerInstance
final static MediaPlayer getMediaPlayerInstance(Context context)
Creates a MediaPlayer instance appropriate for the current Android version.
This function handles the creation of MediaPlayer instances across different Android API levels, using the context-based constructor for newer versions and the legacy constructor for older versions.
- Parameters:
context- The Context for creating the MediaPlayer (used on API 34+)- Returns:
A new MediaPlayer instance
-
setAudioFocusParams
final static Unit setAudioFocusParams(MediaPlayer $self, AudioFocusManager audioFocusManager)
Sets audio focus parameters on the MediaPlayer based on Android version.
This function configures the MediaPlayer's audio attributes for proper audio focus handling, using AudioAttributes for newer Android versions and legacy audio stream type for older versions.
- Parameters:
audioFocusManager- The AudioFocusManager containing audio attributes
-
-
-
-