-
-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stop / pause the video #68
Comments
i just found two methods i think might gonna work, but i am not sure
these are both methods i found in the inner class. is that possible to handle pause effect through these two methods? |
@plutonem-mobile This requirement is addressed, but not perfectly in Kohii, due to various reason. If you want to try out, please find the information below:
val kohii = Kohii[context]
val manager = kohii.register(fragment)
.addBucket(recyclerView)
kohii.setUp(videoUri) {
tag = "myUniqueTag" // you need a unique tag to make it works
controller = DefaultControlDispatcher(
manager,
playerView,
kohiiCanStart = false, // set to false -> if user pause it, Kohii will not start it
kohiiCanPause = true // set to true -> Kohii will pause it automatically
)
}
.bind(playerView) By changing the value of |
okay, thanks eneim, i will try in later then. |
I just try your method but i found that it is little bit out of my point. the design i made is when the user click the playerView, then the video will pause directly without the control panel appear. and the user could click again to resume the video. is there a better way other than the method i send upward to also achieve this kind of design pattern? (pause without showing control panel) |
For your use case, please try the practice below:
class MyController(
val manager: Manager,
val container: ViewGroup
) : OnClickListener, Controller {
override fun kohiiCanStart() = true
override fun kohiiCanPause() = true
override fun onClick(v: View?) {
val playable = manager.findPlayableForContainer(container)
if (playable != null) {
if (playable.isPlaying()) manager.pause(playable)
else manager.play(playable)
}
}
}
val myController = MyController(manager, playerView)
kohii.setUp(videoUri) {
tag = "my-unique-tag"
controller = myController
}
.bind(playerView) Also set the click listener:
Note that sometime the PlayerView is not clickable, I have no idea but in that case you may need to wrap it by a FrameLayout or something. You need to set the click listener to that View instead. |
perfect, this method has got me what i want. just wish kohii could be even better XD. |
@plutonem-mobile Thanks. Your feedback is indeed help to improve it. |
@eneim Man, you are a rockstar!! |
I am using the following versions of thi lib: implementation "im.ene.kohii:kohii-exoplayer:1.1.1.2011003" I cant able to find method findPlayableForContainer(container) in Manager class . So will you please provide some update snippet of code regarding pause/play video with user interaction. I am using your lib in JAVA code. Thanks in advance. |
@Nishit79 can you create this in a new issue? Your issue was in a closed one so I could not be notified by it. I will take a look at this soon. |
@Nishit79 to get the playable instance, you need the Playback instance. Please find a snippet below kohii.setUp(videoUrl)
.bind(container, playback -> {
Playable playable = playback.getPlayable();
// Do something with the playable.
return Unit.INSTANCE; // Need to return this.
}); |
Hi eneim, can you show me the way to stop the video when user click the playerView.
I tried methods like pause() in manager but not ganna work and i cannot find way like stop() method in exoplayer.
The text was updated successfully, but these errors were encountered: