Giter VIP home page Giter VIP logo

Comments (9)

iregados avatar iregados commented on August 24, 2024 2

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.

iregados avatar iregados commented on August 24, 2024

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.

iregados avatar iregados commented on August 24, 2024

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.

eneim avatar eneim commented on August 24, 2024

@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.

iregados avatar iregados commented on August 24, 2024

from kohii.

eneim avatar eneim commented on August 24, 2024

@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.

crema-git avatar crema-git commented on August 24, 2024

@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.

rahul-sysquare avatar rahul-sysquare commented on August 24, 2024

@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.

eneim avatar eneim commented on August 24, 2024

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)

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.