Created
March 9, 2018 01:11
-
-
Save nazmulidris/30808051141a3e7342ee48f3f6a01c7a 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
override fun onCreate(savedInstanceState: Bundle?) { | |
... | |
playerHolder = PlayerHolder(this, exoplayerview_activity_video, state) | |
mediaSession = MediaSessionCompat(this, packageName) | |
connector = MediaSessionConnector(mediaSession) | |
} | |
override fun onStart() { | |
... | |
playerHolder.start() | |
// Note: do not pass a null to the 3rd param below, it will cause a NPE | |
connector.setPlayer(playerHolder.player, null) | |
mediaSession.isActive = true | |
} | |
override fun onStop() { | |
... | |
playerHolder.stop() | |
connector.setPlayer(null, null) | |
mediaSession.isActive = false | |
} | |
override fun onDestroy() { | |
... | |
mediaSession.release() | |
playerHolder.release() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment