Giter Site home page Giter Site logo

Comments (4)

eneim avatar eneim commented on June 12, 2024 1

Just tried this using the same version:

Index: kohii-sample/src/main/java/kohii/v1/sample/ui/grid/ItemsAdapter.kt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- kohii-sample/src/main/java/kohii/v1/sample/ui/grid/ItemsAdapter.kt	(revision e936e2c8e7043cdf5a0ef589972226ebab3d5c99)
+++ kohii-sample/src/main/java/kohii/v1/sample/ui/grid/ItemsAdapter.kt	(date 1622720174945)
@@ -72,7 +72,9 @@
           tag = requireNotNull(videoTag)
           artworkHintListener = holder
         }
-            .bind(holder.container)
+            .bind(holder.container) { playback ->
+              playback.addStateListener(holder)
+            }
       }
     } else holder.bind(position)
   }

Where the ViewHolder implements the Playback.StateListener

Index: kohii-sample/src/main/java/kohii/v1/sample/ui/grid/VideoViewHolder.kt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- kohii-sample/src/main/java/kohii/v1/sample/ui/grid/VideoViewHolder.kt	(revision e936e2c8e7043cdf5a0ef589972226ebab3d5c99)
+++ kohii-sample/src/main/java/kohii/v1/sample/ui/grid/VideoViewHolder.kt	(date 1622720157556)
@@ -26,10 +26,13 @@
 import kohii.v1.core.Rebinder
 import kohii.v1.sample.R
 import kohii.v1.sample.common.BaseViewHolder
+import timber.log.Timber
 
 internal class VideoViewHolder(
   parent: ViewGroup
-) : BaseViewHolder(parent, R.layout.holder_player_container), Playback.ArtworkHintListener {
+) : BaseViewHolder(parent, R.layout.holder_player_container),
+    Playback.ArtworkHintListener,
+    Playback.StateListener {
 
   private val root: AspectRatioFrameLayout = itemView.findViewById(R.id.playerContainer)
   internal val container: FrameLayout = itemView.findViewById(R.id.container)
@@ -76,4 +79,40 @@
         }
         .start()
   }
+
+  //region Playback.StateListener
+  override fun onRendered(playback: Playback) {
+    Timber.i("onRendered ${playback.tag}")
+  }
+
+  override fun onBuffering(playback: Playback, playWhenReady: Boolean) {
+    Timber.i("onBuffering ${playback.tag}")
+  }
+
+  override fun onPlaying(playback: Playback) {
+    Timber.i("onPlaying ${playback.tag}")
+  }
+
+  override fun onPaused(playback: Playback) {
+    Timber.i("onPaused ${playback.tag}")
+  }
+
+  override fun onEnded(playback: Playback) {
+    Timber.i("onEnded ${playback.tag}")
+  }
+
+  override fun onVideoSizeChanged(
+    playback: Playback,
+    width: Int,
+    height: Int,
+    unAppliedRotationDegrees: Int,
+    pixelWidthHeightRatio: Float
+  ) {
+    Timber.i("onVideoSizeChanged ${playback.tag}")
+  }
+
+  override fun onError(playback: Playback, exception: Exception) {
+    Timber.i("onError ${playback.tag}")
+  }
+  //endregion
 }

and it works well:

I/VideoViewHolder: onBuffering HOLDER::〜3
I/VideoViewHolder: onBuffering HOLDER::〜3
I/VideoViewHolder: onVideoSizeChanged HOLDER::〜3
I/VideoViewHolder: onRendered HOLDER::〜3
I/VideoViewHolder: onPlaying HOLDER::〜3
I/VideoViewHolder: onEnded HOLDER::〜3

Is this what you want to do? Can you double check, or share your setup that doesn't work as expected?

from kohii.

FujiKinaga avatar FujiKinaga commented on June 12, 2024 1

@eneim
I checked the comments you gave and my implementation.
It's clear.
I tried to create custom bridge class like a PlayerViewBridge.kt in exo-kohiiplayer module.
But then, my custom class was not seem to be called Player.addListener...😅

This is due to my implementation. I apologize for the inconvenience😣

from kohii.

eneim avatar eneim commented on June 12, 2024

@FujiKinaga Oh it must be an issue. Let me check the current status. Can you tell me which version you are using?

from kohii.

FujiKinaga avatar FujiKinaga commented on June 12, 2024

@eneim
Thanks for your confirmation.
I'm using v1.2.0.2011008 now.

from kohii.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.