Comments (9)
done it...had to "clear" the PlayerViews as i scroll...something like Glide does with .clear().....if there is a video on my holder i setup the right url...if there is no video on my holder i setup an empty url and bind it to the gone PlayerView just to avoid recycling mistakes...
is it right?
Man such a powerfull library and yet really simple to work with....you are a monster
from kohii.
achieved it when i setted the controller also, like
kohii.setUp(videoUrl!!) {
tag = "${videoUrl}+${position}"
threshold = .8F
controller = object : Playback.Controller {
override fun kohiiCanStart(): Boolean = true
override fun kohiiCanPause(): Boolean = true
}
}.bind(holder.binding.videoExoplayer){ playback ->
val playable = playback.playable
val myController = MyController(playable, manager)
holder.binding.videoExoplayer.setOnClickListener(myController)
KParameter.Kind.INSTANCE
}
now I got another problem, when i pause the video there is no image remaining on screen, it's totally gone, is it possible to let the paused video image on screen when paused?
another doubt, is it possible to set something like "center_crop" to the video?
sometimes I got images on the adapter and sometimes videos, the images are center crop, if the video is not center cropped it looks kinda strange when compared to the images...
from kohii.
ok i believe that I am almost there, now i have done
<FrameLayout
android:id="@+id/playerViewContainer"
app:layout_constraintTop_toTopOf="parent"
android:visibility='@{(tweet.retweetedStatus == null ? tweet : tweet.retweetedStatus).mediaEntities.size() > 0 ? ((tweet.retweetedStatus == null ? tweet : tweet.retweetedStatus).mediaEntities[0].type.equals("photo") ) ? View.GONE : View.VISIBLE : View.GONE}'
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/black">
<com.google.android.exoplayer2.ui.PlayerView
android:id="@+id/playerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:resize_mode="fixed_width"/>
</FrameLayout>
on my layout file as you recommend in one of your tutorials
I am setting the playerView height with a globalLayoutListener because every video can get a different aspect ratio..
my rebinder looks like:
kohii.setUp(videoUrl!!) {
tag = "${videoUrl}+${position}"
threshold = .8F
repeatMode = Common.REPEAT_MODE_ALL
controller = object : Playback.Controller {
override fun kohiiCanStart(): Boolean = false
override fun kohiiCanPause(): Boolean = true
override fun setupRenderer(playback: Playback, renderer: Any?) {
val playable = playback.playable ?: return
playback.manager.play(playable)
playerViewContainer.setOnClickListener {
if (playable.isPlaying()) {
playback.manager.pause(playable)
} else {
playback.manager.play(playable)
}
}
}
}
}.bind(playerView)
The video is there, if i pause it the image remains there, the dimension is ok, but while scrolling something wired happens, previous video's sound start randomly playing even if there is no playerView on screen, its like its not released i believe..
should I do anything to release it on my adapter?
from kohii.
@iregados I saw you have solved the play/pause on click issue. So the remaining issue is:
if i pause it the image remains there, the dimension is ok, but while scrolling something wired happens, previous video's sound start randomly playing even if there is no playerView on screen, its like its not released i believe
I believe. I will try to reproduce and see.
from kohii.
from kohii.
@iregados Thanks for the kind words. I also acknowledge that the RecyclerView may behave weird. Something a View not in the viewport is attached, etc. I actually try to address that by calculating the View's coordinator and some other metric to know if it is visible or not. Though it maybe not yet enough. I will look into both, one is a kill-switch that client can use in such cases, another thing is to see what can the library do automatically as well.
from kohii.
@iregados Could you please share the code snaps that worked for you?
I am using the following code base but didn't work for me
kohii.setUp(media.getMediaUrl()) {
threshold = 0.5F
preload = true
repeatMode = Player.REPEAT_MODE_ONE
controller = object : Playback.Controller {
override fun kohiiCanStart(): Boolean = true
override fun kohiiCanPause(): Boolean = true
override fun setupRenderer(playback: Playback, renderer: Any?) {
binding.playerContainer.setOnClickListener {
val playable = playback.playable ?: return@setOnClickListener
if (playable.isPlaying()) {
playback.manager.pause(playable)
} else {
playback.manager.play(playable)
}
}
}
}
}.bind(binding.container);
but in case I add the tag it will start working but hide the videoview on pause
from kohii.
@iregados Could you please share the code snaps that worked for you? I am using the following code base but didn't work for me
kohii.setUp(media.getMediaUrl()) { threshold = 0.5F preload = true repeatMode = Player.REPEAT_MODE_ONE controller = object : Playback.Controller { override fun kohiiCanStart(): Boolean = true override fun kohiiCanPause(): Boolean = true override fun setupRenderer(playback: Playback, renderer: Any?) { binding.playerContainer.setOnClickListener { val playable = playback.playable ?: return@setOnClickListener if (playable.isPlaying()) { playback.manager.pause(playable) } else { playback.manager.play(playable) } } } } }.bind(binding.container);
but in case I add the tag it will start working but hide the videoview on pause
@eneim @iregados @sdex does anyone have any solutions for this?
from kohii.
but in case I add the tag it will start working but hide the videoview on pause
You can use PlayerView rather than a non-PlayerView. The PlayerView will not be removed for recycling.
For debugging, I suggest using another View in the same ViewHolder to receive the click event (replace binding.playerContainer.setOnClickListener
by something else like binding.customButton.setOnClickListener {}
).
from kohii.
Related Issues (20)
- Playback.StateListener not return any value HOT 4
- How to stop video playback when the app goes to background HOT 2
- Is the library production ready? HOT 1
- Play Video In Nested Recyclerview
- Why does not you play music in the video? I mean in Recyclerview ... HOT 1
- java.lang.NoSuchMethodError: No static method getNetworkType HOT 2
- Project not building in current stable version of android studio bumblebee HOT 1
- Kohii crash when use exoplayer 2.13.3 NoClassDefFoundError TrackSelection HOT 2
- Kohii with fragment replace HOT 2
- Kohii vs Toro and development status HOT 3
- Caching Video
- is Kohii better than Toro ? HOT 2
- Black Screen while move next video in Recycleview HOT 16
- Can't replay and black screen while play video with same tag in Recycleview HOT 1
- How to change SeekForwardIncrementMs and SeekBackIncrementMs
- Is there any way to play the video from starting every time in Recyclerview, currently it's playing from the same position when it left last time during the scroll HOT 2
- Getting black screen in recyclerview while scrolling video HOT 4
- pausing video shows black screen instead of video frame HOT 6
- Support for Media3 API's HOT 4
- Replay video after end on tap of a button
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kohii.