This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Player { | |
val player: ExoPlayer = ExoPlayerFactory.newInstance(...) | |
var wasPlaying = player.playWhenReady | |
fun start() { | |
wasPlaying = player.playWhenReady | |
player.playWhenReady = true | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Player { | |
interface ProgressionListener { | |
val interval: Long | |
fun progression(position: Long, duration: Long) | |
} | |
private inner class RunnableProgression(val progressionListener: ProgressionListener) : Runnable { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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( |