Created
July 31, 2020 10:21
-
-
Save halilozercan/79f5c2eefdd2b5242f9c9b17b31420c9 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 PlayerController( | |
| private val context: Context | |
| ) { | |
| private val exoPlayer by lazy { | |
| SimpleExoPlayer.Builder(context).build() | |
| } | |
| fun prepare(sourceUrl: String) { | |
| val dataSourceFactory: DataSource.Factory = DefaultDataSourceFactory(context, | |
| Util.getUserAgent(context, context.packageName)) | |
| val source = ProgressiveMediaSource.Factory(dataSourceFactory) | |
| .createMediaSource(Uri.parse( | |
| // Big Buck Bunny from Blender Project | |
| sourceUrl | |
| )) | |
| exoPlayer.prepare(source) | |
| } | |
| fun setPlayerView(playerView: PlayerView) { | |
| playerView.player = exoPlayer | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment