eneim/toro

Black Background after removing thumbnail

Opened this issue · 1 comments

Hello. In my adapter I set up an ImageView in front of the player to be used as a thumbnail and remove it when the video starts playing. However after hiding the thumbnail, the video takes a few seconds to load and turns black and only then starts playing.
How can I make a smoother transition?
Thanks in advance and thanks for this library.

        //TORO
        override fun getPlayerView(): View {
            Log.i("TORO","getPlayerView")
            if(helper != null && helper!!.isPlaying){
                thumbVideoPostagem.setVisibility(View.GONE)
            }
            return videoPostagem
        }

        override fun initialize(container: Container, playbackInfo: PlaybackInfo) {
            if (helper == null) {
                helper = ExoPlayerViewHelper(this, videoUri)
            }
            helper!!.initialize(container, playbackInfo)
            Log.i("TORO","initialize")
        }

        override fun getCurrentPlaybackInfo(): PlaybackInfo {
            Log.i("TORO","getCurrentPlaybackInfo")
            return if (helper != null) helper!!.getLatestPlaybackInfo() else PlaybackInfo()
        }

        override fun release() {
            if (helper != null) {
                helper!!.release()
                Log.i("TORO","release")
                helper = null
            }
        }

        override fun play() {
            Log.i("TORO","play")
            if (helper != null) helper!!.play()
        }

        override fun pause() {
            Log.i("TORO","pause")
            if (helper != null) helper!!.pause()
        }

        override fun isPlaying(): Boolean {
            Log.i("TORO","isPlaying")
            return helper != null && helper!!.isPlaying()
        }

        override fun wantsToPlay(): Boolean {
            Log.i("TORO","wantsToPlay")
            return ToroUtil.visibleAreaOffset(this, itemView.parent) >= 0.85
        }

        override fun getPlayerOrder(): Int {
            Log.i("TORO","getPlayerOrder")
            return adapterPosition
        }
    }

Hi!

If your ViewHolder implements ToroPlayer.EventListener you have a method to implement called onPlaying(), in this method you can hide your thumbnail.

To add the listener you need to call helper.addPlayerEventListener(this) . on initialize Toro

Greetings!