From b0fe19aec57017afeab50d2bd8274c99d5c20a34 Mon Sep 17 00:00:00 2001 From: ThibaultBee <37510686+ThibaultBee@users.noreply.github.com> Date: Mon, 30 Oct 2023 17:43:12 +0100 Subject: [PATCH] feat(*): simplify full screen management. `showFullScreenButton` is replaced by `fullScreenListener` --- README.md | 1 - .../video/api/compose/player/ApiVideoPlayer.kt | 2 +- .../java/video/api/player/example/MainActivity.kt | 10 ++++++---- .../view/src/main/res/layout/activity_main.xml | 1 - .../api/player/views/ApiVideoExoPlayerView.kt | 15 ++++++--------- player/src/main/res/values/attrs.xml | 1 - 6 files changed, 13 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index f8ec230..a80191d 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,6 @@ analytics of [your viewers usage](https://api.video/product/video-analytics/). android:id="@+id/playerView" android:layout_width="wrap_content" android:layout_height="wrap_content" - app:show_fullscreen_button="true" app:show_controls="true" app:show_subtitles="true" /> ``` diff --git a/compose-player/src/main/java/video/api/compose/player/ApiVideoPlayer.kt b/compose-player/src/main/java/video/api/compose/player/ApiVideoPlayer.kt index 48539e8..e0d4c8d 100644 --- a/compose-player/src/main/java/video/api/compose/player/ApiVideoPlayer.kt +++ b/compose-player/src/main/java/video/api/compose/player/ApiVideoPlayer.kt @@ -82,7 +82,7 @@ fun ApiVideoPlayer( factory = { playerView.apply { controller.setPlayerView(this) - showFullScreenButton = false + this.fullScreenListener = null this.showControls = showControls this.showSubtitles = showSubtitles } diff --git a/examples/view/src/main/java/video/api/player/example/MainActivity.kt b/examples/view/src/main/java/video/api/player/example/MainActivity.kt index 0e855cb..01313c0 100644 --- a/examples/view/src/main/java/video/api/player/example/MainActivity.kt +++ b/examples/view/src/main/java/video/api/player/example/MainActivity.kt @@ -51,7 +51,7 @@ class MainActivity : AppCompatActivity() { } } - private val playerViewListener = object : ApiVideoExoPlayerView.Listener { + private val fullScreenListener = object : ApiVideoExoPlayerView.FullScreenListener { override fun onFullScreenModeChanged(isFullScreen: Boolean) { /** * For fullscreen video, hides every views and forces orientation in landscape. @@ -84,9 +84,11 @@ class MainActivity : AppCompatActivity() { error.message != null -> { error.message } + error is ClientError -> { error.networkResponse.statusCode.toString() } + else -> { error.toString() } @@ -124,7 +126,7 @@ class MainActivity : AppCompatActivity() { } private val playerController: ApiVideoPlayerController by lazy { - binding.playerView.listener = playerViewListener + binding.playerView.fullScreenListener = fullScreenListener ApiVideoPlayerController( applicationContext, null, @@ -186,10 +188,10 @@ class MainActivity : AppCompatActivity() { binding.unmute.setOnClickListener { playerController.isMuted = false } binding.showFullScreenButton.setOnClickListener { - binding.playerView.showFullScreenButton = true + binding.playerView.fullScreenListener = fullScreenListener } binding.hideFullScreenButton.setOnClickListener { - binding.playerView.showFullScreenButton = false + binding.playerView.fullScreenListener = null } binding.showControls.setOnClickListener { binding.playerView.showControls = true } diff --git a/examples/view/src/main/res/layout/activity_main.xml b/examples/view/src/main/res/layout/activity_main.xml index 9d631f3..635ed2b 100644 --- a/examples/view/src/main/res/layout/activity_main.xml +++ b/examples/view/src/main/res/layout/activity_main.xml @@ -25,7 +25,6 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" app:show_controls="true" - app:show_fullscreen_button="true" app:show_subtitles="true" /> -