toro
toro copied to clipboard
How to disable auto play
How to disable auto play, but user can still play/pause manualy? or disable auto play when network is on GPRS, and enabl auto play when on WIFI or 4G?
@j3p0n You can have your own Strategy which does nothing, for example a lazyStrategy. So when you want to disable auto playback, just call Toro.setStrategy(lazyStrategy). See how I implement Toro.rest(boolean) for more information.
I created own lazyStrategy and called Toro.setStrategy(lazyStrategy) playback was disabled, but how to pause/play video when user clicks on video?. In this case adapter.getPlayer() returns null.
This intention of this library is to solely autoplay videos one at a time which it does nicely.
Quickfix - for temporarily disabling autoplay, inside the viewholder that extends ToroPlayer
, there a method play()
. Just add playerView.getPlayer().setPlayWhenReady(false)
after the exoplayerViewHelper.play()
.
@foodied You can always return a 'conditional false' from wantsToPlay
(assuming that you are using Toro 3.x) ;). It will disable the auto play for a certain ToroPlayer. To disable that for all players, you can use PlayerSelector.NONE
for the Container.
I did set the container.setPlayerSelector(PlayerSelector.NONE)
but it seems that video is not loaded as it comes to the center. It just shows the shutter view. I am using the 3.4.2 version of the lib
.
@foodied Yep, it will not start loading (SimpleExoPlayer will not call 'prepare') if you don't have it starts. You can put a thumbnail view on top to hide the black screen though ... What is the behaviour you demand?
Well, I guess immediate playback without any buffering when I click on play.
@foodied "immediate playback without any buffering" you mean that [1] Do not start the playback automatically, but [2] When click to play button (so User has a chance to manually start the playback), it will start right away (which is equal to that the MediaSource is already ready for playback)?
This can be archive by create your own version of "ExoPlayerViewHelper" (copy/paste should work), and instead of calling playable.prepare(false)
you can call playable.prepare(true)
. This way, it will start loading the source as soon as possible.
See this line for reference.
Yes, I guess that would work as well along with PlayerSelector.NONE
. Thanks! Btw do you think of any side-effects of the line that I suggested?
@foodied Please try that and tell me if it doesn't work well for you. I disable the loading by default to save the resource and improve scrolling performance. It should be on-demand, I will consider to have an option to turn it on-off in next release.
EventListeners
inside Playable
is not public. The default constructor EventListeners()
has been made package-private.
@foodied which version of Java you are compiling with? Java 7+ will allow EventListeners
to be accessible by default (it is a class inside a public interface).
@eneim Should the container.setPlayerSelector(PlayerSelector.NONE)
be called before the container is populated? Looks like setPlayerSelecter
doesn't work when called after the container is already populated and scrolled.