From 87867b6738f44c5a3666374885f66cc64a26f07c Mon Sep 17 00:00:00 2001 From: Weian Date: Wed, 21 Feb 2018 09:33:16 +0800 Subject: [PATCH] add a new handler for dealing download mp3 from remote server. --- .../mediaplayerwitexoplayer/MainActivity.kt | 10 ++ .../src/main/AndroidManifest.xml | 5 +- .../DownloadHandler.kt | 99 +++++++++++++++++++ .../ExoPlayerEventListener.kt | 6 ++ .../ExoPlayerWrapper.kt | 22 ++++- .../mediaplayerwithexoplayer/IMusicPlayer.kt | 8 +- 6 files changed, 143 insertions(+), 7 deletions(-) create mode 100644 mediaplayerwithexoplayer2/src/main/java/weian/cheng/mediaplayerwithexoplayer/DownloadHandler.kt diff --git a/app/src/main/java/weian/cheng/mediaplayerwitexoplayer/MainActivity.kt b/app/src/main/java/weian/cheng/mediaplayerwitexoplayer/MainActivity.kt index a5b755a..1e98594 100644 --- a/app/src/main/java/weian/cheng/mediaplayerwitexoplayer/MainActivity.kt +++ b/app/src/main/java/weian/cheng/mediaplayerwitexoplayer/MainActivity.kt @@ -37,6 +37,10 @@ class MainActivity:AppCompatActivity() { onPlayerStateChanged = { state -> Log.i("MainActivity", "onPlayerStateChanged: $state") } + + onDownloadTrack = { isSuccess -> + Log.i("MainActivity", "onDownloadTrack: $isSuccess") + } } override fun onCreate(savedInstanceState:Bundle?) { @@ -51,6 +55,12 @@ class MainActivity:AppCompatActivity() { val play = findViewById