/Toro

Video list auto playback made simple, specially built for RecyclerView

Primary LanguageJavaOtherNOASSERTION

Toro

Join the chat at https://gitter.im/eneim/Toro Android Arsenal

Video list auto playback made simple, specially built for RecyclerView

1. Main features:

  • Auto start/pause/resume video by scrolling your RecyclerView, support all Official built-in LayoutManagers.

  • Smart caching: Toro remembers last playback position and resume from where you left (note: in Android default Media Player, depend on Video's format and codec, the resume timestamp may varies).

  • Playback behavior decided by User, not by library:

    • Customizable playback Strategy to decide which is the best component to start playback. Optimized built-in Strategies to help you start.
    • UI-based logic, straight-forward approach: you see the Video, then it should play. Default: you see 75% of the Video then it should start playing. Advance: you decide how much the visible Video should trigger the playback. See Wiki for more details.
    • Decision from both side: Toro's core and your implementation. Toro listens to your widget: does it want to play?, is it able to play (video is well-prepared or not), then Toro's strategy will decide if it allows your video to play or not. Default: built-in Strategy and widget do the rest. Advance: you have control to the both side: your custom ViewHolder and your custom Strategy. See Wiki for more details.
  • Built-in widgets: an abstract ViewHolder for original VideoView, an abstract ViewHolder for "TextureView version" of VideoView: TextureVideoView, and an abstract ViewHolder for my customized version of TextureVideoView: ToroVideoView, with more flexible API and less annoying error processing.

  • Powerful, flexible and highly customizable API. See Wiki for more details.

  • Selective playback: find the best playable item, defined by smart, flexible Strategies to decide when and how a player should start playing. Toro comes with optimized built-in Strategies, but user could always create their own. See Wiki for more details.

  • Smart long press: support Grid (with many Videos in one window) by built-in Long press listener. Turning ON/OFF in one line of code. See Wiki for more details.

  • I create lots of built-in components, but keep Toro highly customizable. You are free to decide how you want to start your player, but if you don't know, just let Toro help you to decide.

See Wiki for more details.

2. Toro in Action

3. How to use

0. Prerequirement
  • Min support version: Android SDK level 15 (4.0.x)
1. Add Toro to your project
  • Add this to Project's top level build.gradle
allprojects {
	repositories {
		maven { url "https://jitpack.io" }
	}
}
  • Add this to dependencies
ext {
	toro_latest_version = '1.2.0'
}

dependencies {
	compile "com.github.eneim:Toro:${toro_latest_version}"
}

Latest version is always visible by jitpack badge:

TL,DR: app module from this library comes with several good practice of this library. Please take a look.
2. Integrate Toro into your Application: see Toro starting guide
3. Register/Unregister a RecyclerView to get support from Toro: see Register/Unregister RecyclerView to Toro
4. Create ViewHolder to use with Toro: by default, just simply extend one of ToroVideoViewHolder, TextureVideoViewHolder or AbsVideoViewHolder. See ToroViewHolder for more information.
  • A sample ViewHolder's code (see Sample app for more):
public class DeadlySimpleToroVideoViewHolder extends ToroVideoViewHolder {

  public DeadlySimpleToroVideoViewHolder(View itemView) {
    super(itemView);
  }

  @Override protected ToroVideoView findVideoView(View itemView) {
    return (ToroVideoView) itemView.findViewById(R.id.video);
  }

  @Nullable @Override public String getVideoId() {
    return "my awesome video's id and its order: " + getAdapterPosition();
  }

  @Override public void bind(@Nullable Object object) {
    if (object != null && object instanceof SimpleVideoObject) {
      mVideoView.setVideoPath(((SimpleVideoObject) object).video);
    }
  }
}
5. Core concepts and components of Toro: see Wiki

Contribute to Toro

  • Issue report and PRs are welcome.

License

Copyright 2016 eneim@Eneim Labs, nam@ene.im

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.