Skip to content

Instantly share code, notes, and snippets.

View q-litzler's full-sized avatar

qlitzler q-litzler

View GitHub Profile
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(
@q-litzler
q-litzler / SeekBarProgressionListener.kt
Created May 14, 2017 15:02
ExoPlayer Tip 4: Bonus
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
@q-litzler
q-litzler / Player.kt
Last active May 14, 2017 14:57
ExoPlayer Short Tip 4: Playback Progression
class Player {
interface ProgressionListener {
val interval: Long
fun progression(position: Long, duration: Long)
}
private inner class RunnableProgression(val progressionListener: ProgressionListener) : Runnable {
@q-litzler
q-litzler / Player.kt
Last active September 28, 2021 05:51
ExoPlayer Short Tip 3: The Android Lifecycle
class Player {
val player: ExoPlayer = ExoPlayerFactory.newInstance(...)
var wasPlaying = player.playWhenReady
fun start() {
wasPlaying = player.playWhenReady
player.playWhenReady = true
}
@q-litzler
q-litzler / ConcatenatingMediaSourceWindowIndex.kt
Last active May 14, 2017 14:05
ConcatenatingMediaSource WindowIndex change
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 {