Created
March 8, 2018 23:01
-
-
Save nazmulidris/6d02ac7e4f64ad86c61a2d081c18ca49 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 PlayerHolder(...) : AnkoLogger { | |
| ... | |
| fun start() { | |
| // Load media. | |
| player.prepare(...) | |
| // Restore state (after onResume()/onStart()) | |
| with(playerState) { | |
| // Start playback when media has buffered enough | |
| // (whenReady is true by default). | |
| player.playWhenReady = whenReady | |
| player.seekTo(window, position) | |
| } | |
| info { "SimpleExoPlayer is started" } | |
| } | |
| fun stop() { | |
| with(player) { | |
| // Save state | |
| with(state) { | |
| position = currentPosition | |
| window = currentWindowIndex | |
| whenReady = playWhenReady | |
| } | |
| // Stop the player. | |
| stop() | |
| } | |
| info { "SimpleExoPlayer is released" } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment