View gist:a67dfe50d35c7ec1e3bc50b953bc2d43
class ActivityHome : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val transport = NetHttpTransport()
val jsonFactory = JacksonFactory.getDefaultInstance()
val request = YouTubeRequestInitializer("my-youtube-api-key-3")
val service = YouTube.Builder(
View SeekBarProgressionListener.kt
class SeekBarProgressionListener : Player.ProgressionListener {
override val interval: Long = 1000 / 60L
override fun progression(position: Long, duration: Long) {
val progress = (position * view.skbPlayerContent.max / duration).toInt()
val progressBuffer = (player.exoPlayer.bufferedPosition * view.skbPlayerContent.max / duration).toInt()
view.skbPlayerContent.progress = progress
view.skbPlayerContent.secondaryProgress = progressBuffer
View Player.kt
class Player {
interface ProgressionListener {
val interval: Long
fun progression(position: Long, duration: Long)
}
private inner class RunnableProgression(val progressionListener: ProgressionListener) : Runnable {
View Player.kt
class Player {
val player: ExoPlayer = ExoPlayerFactory.newInstance(...)
var wasPlaying = player.playWhenReady
fun start() {
wasPlaying = player.playWhenReady
player.playWhenReady = true
}
View ConcatenatingMediaSourceWindowIndex.kt
var currentIndex: Int = 0
var player : ExoPlayer
var handler = Handler()
fun onNewWindowIndex(index: Int) {
currentIndex = index
// Do something with your playlist using this reliable index
}
class PlayerEventListener: ExoPlayer.Listener {