Skip to content

Commit

Permalink
chore(player): remove deprecated warnings, improve documentations
Browse files Browse the repository at this point in the history
  • Loading branch information
ThibaultBee committed Oct 27, 2023
1 parent e169267 commit 655d58c
Showing 1 changed file with 69 additions and 4 deletions.
73 changes: 69 additions & 4 deletions player/src/main/java/video/api/player/ApiVideoPlayerController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,21 @@ import video.api.player.interfaces.ISurfaceViewBasedPlayerView
import video.api.player.models.ApiVideoExoPlayerMediaFactory
import video.api.player.models.VideoOptions
import video.api.player.notifications.ApiVideoPlayerNotificationController
import video.api.player.views.ApiVideoExoPlayerView
import java.io.IOException

/**
* The api.video player controller class.
*
* @param context the application context
* @param initialVideoOptions initial video options
* @param initialAutoplay initial autoplay: true to play the video immediately, false otherwise
* @param listener a [ApiVideoPlayerController.Listener] to listen to player events
* @param looper the looper where call to the player are executed. By default, it is the current looper or the main looper.
* @constructor Creates a new controller without a view.
*/
class ApiVideoPlayerController
internal constructor(
constructor(
private val context: Context,
initialVideoOptions: VideoOptions? = null,
initialAutoplay: Boolean = false,
Expand All @@ -54,8 +57,11 @@ internal constructor(
private val notificationController: ApiVideoPlayerNotificationController? = null
) {
/**
* Creates a new controller with an [IExoPlayerBasedPlayerView].
*
* @param context the application context
* @param initialVideoOptions initial video options
* @param initialAutoplay initial autoplay: true to play the video immediately, false otherwise
* @param listener the [ApiVideoPlayerController.Listener] to listen to player events
* @param playerView the [IExoPlayerBasedPlayerView] interface for ExoPlayer [PlayerView] based player view
* @param looper the looper where call to the player are executed. By default, it is the current looper or the main looper.
Expand Down Expand Up @@ -83,8 +89,11 @@ internal constructor(
}

/**
* Creates a new controller with an [ISurfaceViewBasedPlayerView].
*
* @param context the application context
* @param initialVideoOptions initial video options
* @param initialAutoplay initial autoplay: true to play the video immediately, false otherwise
* @param listener the [ApiVideoPlayerController.Listener] to listen to player events
* @param playerView the [ISurfaceViewBasedPlayerView] interface for [SurfaceView] based player view
* @param looper the looper where call to the player are executed. By default, it is the current looper or the main looper.
Expand Down Expand Up @@ -112,8 +121,11 @@ internal constructor(
}

/**
* Creates a new controller with a `media3` [PlayerView].
*
* @param context the application context
* @param initialVideoOptions initial video options
* @param initialAutoplay initial autoplay: true to play the video immediately, false otherwise
* @param listener the [ApiVideoPlayerController.Listener] to listen to player events
* @param playerView the [PlayerView] to use to display the player
* @param looper the looper where call to the player are executed. By default, it is the current looper or the main looper.
Expand All @@ -140,8 +152,11 @@ internal constructor(
}

/**
* Creates a new controller with a [SurfaceView].
*
* @param context the application context
* @param initialVideoOptions initial video options
* @param initialAutoplay initial autoplay: true to play the video immediately, false otherwise
* @param listener the [ApiVideoPlayerController.Listener] to listen to player events
* @param surfaceView the [SurfaceView] to use to display the video
* @param looper the looper where call to the player are executed. By default, it is the current looper or the main looper.
Expand All @@ -168,8 +183,11 @@ internal constructor(
}

/**
* Creates a new controller with a [Surface].
*
* @param context the application context
* @param initialVideoOptions initial video options
* @param initialAutoplay initial autoplay: true to play the video immediately, false otherwise
* @param listener the [ApiVideoPlayerController.Listener] to listen to player events
* @param surface the [Surface] to use to display the video
* @param looper the looper where call to the player are executed. By default, it is the current looper or the main looper.
Expand Down Expand Up @@ -410,7 +428,7 @@ internal constructor(
* @param value true if the device is muted, false otherwise
*/
set(value) {
exoplayer.isDeviceMuted = value
exoplayer.setDeviceMuted(value, 0)
}

/**
Expand All @@ -429,8 +447,10 @@ internal constructor(
* @param value volume between 0 and 1.0
*/
set(value) {
exoplayer.deviceVolume =
(value * (exoplayer.deviceInfo.maxVolume - exoplayer.deviceInfo.minVolume) + exoplayer.deviceInfo.minVolume).toInt()
exoplayer.setDeviceVolume(
(value * (exoplayer.deviceInfo.maxVolume - exoplayer.deviceInfo.minVolume) + exoplayer.deviceInfo.minVolume).toInt(),
0
)
}

/**
Expand Down Expand Up @@ -570,6 +590,51 @@ internal constructor(
exoplayer.release()
}

/**
* Sets the player view
*
* @param view the player view. An [ApiVideoExoPlayerView] for example.
*/
fun setPlayerView(view: IExoPlayerBasedPlayerView) {
view.playerView.player = exoplayer
}

/**
* Sets the player view
*
* @param playerView the [PlayerView]
*/
fun setPlayerView(playerView: PlayerView) {
playerView.player = exoplayer
}

/**
* Sets the player view
*
* @param view the [ISurfaceViewBasedPlayerView]
*/
fun setSurfaceView(view: ISurfaceViewBasedPlayerView) {
exoplayer.setVideoSurfaceView(view.surfaceView)
}

/**
* Sets the player view
*
* @param surfaceView the [SurfaceView]
*/
fun setSurfaceView(surfaceView: SurfaceView) {
exoplayer.setVideoSurfaceView(surfaceView)
}

/**
* Sets the player view
*
* @param surface the [Surface]
*/
fun setSurface(surface: Surface) {
exoplayer.setVideoSurface(surface)
}

companion object {
private const val TAG = "ApiVideoPlayer"
}
Expand Down

0 comments on commit 655d58c

Please sign in to comment.