diff --git a/src/musikdroid/app/build.gradle b/src/musikdroid/app/build.gradle index 4e0e3fc2a..a53d16871 100644 --- a/src/musikdroid/app/build.gradle +++ b/src/musikdroid/app/build.gradle @@ -88,8 +88,8 @@ dependencies { implementation 'io.reactivex.rxjava2:rxjava:2.1.6' implementation 'io.reactivex.rxjava2:rxandroid:2.0.1' implementation 'io.reactivex.rxjava2:rxkotlin:2.1.0' - implementation 'com.google.android.exoplayer:exoplayer:r2.4.2' - implementation 'com.google.android.exoplayer:extension-okhttp:r2.4.2' + implementation 'com.google.android.exoplayer:exoplayer:r2.5.4' + implementation 'com.google.android.exoplayer:extension-okhttp:r2.5.4' implementation 'com.simplecityapps:recyclerview-fastscroll:1.0.16' implementation 'com.facebook.stetho:stetho:1.5.0' diff --git a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/service/playback/impl/player/ExoPlayerWrapper.kt b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/service/playback/impl/player/ExoPlayerWrapper.kt index d00309687..74cbcb82c 100644 --- a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/service/playback/impl/player/ExoPlayerWrapper.kt +++ b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/service/playback/impl/player/ExoPlayerWrapper.kt @@ -52,39 +52,37 @@ class ExoPlayerWrapper : PlayerWrapper() { } synchronized(ExoPlayerWrapper::class.java) { - if (audioStreamHttpClient == null) { - val path = File(context.externalCacheDir, "audio") + val path = File(context.externalCacheDir, "audio") - var diskCacheIndex = prefs.getInt( - Prefs.Key.DISK_CACHE_SIZE_INDEX, Prefs.Default.DISK_CACHE_SIZE_INDEX) + var diskCacheIndex = prefs.getInt( + Prefs.Key.DISK_CACHE_SIZE_INDEX, Prefs.Default.DISK_CACHE_SIZE_INDEX) - if (diskCacheIndex < 0 || diskCacheIndex > StreamProxy.CACHE_SETTING_TO_BYTES.size) { - diskCacheIndex = 0 - } - - val builder = OkHttpClient.Builder() - .cache(Cache(path, StreamProxy.CACHE_SETTING_TO_BYTES[diskCacheIndex] ?: StreamProxy.MINIMUM_CACHE_SIZE_BYTES)) - .addInterceptor { chain -> - var request = chain.request() - val userPass = "default:" + prefs.getString(Prefs.Key.PASSWORD, Prefs.Default.PASSWORD)!! - val encoded = Base64.encodeToString(userPass.toByteArray(), Base64.NO_WRAP) - request = request.newBuilder().addHeader("Authorization", "Basic " + encoded).build() - chain.proceed(request) - } - - if (prefs.getBoolean(Prefs.Key.CERT_VALIDATION_DISABLED, Prefs.Default.CERT_VALIDATION_DISABLED)) { - NetworkUtil.disableCertificateValidation(builder) - } - - audioStreamHttpClient = builder.build() + if (diskCacheIndex < 0 || diskCacheIndex > StreamProxy.CACHE_SETTING_TO_BYTES.size) { + diskCacheIndex = 0 } + + val builder = OkHttpClient.Builder() + .cache(Cache(path, StreamProxy.CACHE_SETTING_TO_BYTES[diskCacheIndex] ?: StreamProxy.MINIMUM_CACHE_SIZE_BYTES)) + .addInterceptor { chain -> + var request = chain.request() + val userPass = "default:" + prefs.getString(Prefs.Key.PASSWORD, Prefs.Default.PASSWORD)!! + val encoded = Base64.encodeToString(userPass.toByteArray(), Base64.NO_WRAP) + request = request.newBuilder().addHeader("Authorization", "Basic " + encoded).build() + chain.proceed(request) + } + + if (prefs.getBoolean(Prefs.Key.CERT_VALIDATION_DISABLED, Prefs.Default.CERT_VALIDATION_DISABLED)) { + NetworkUtil.disableCertificateValidation(builder) + } + + audioStreamHttpClient = builder.build() } if (uri.startsWith("http")) { this.datasources = OkHttpDataSourceFactory( - audioStreamHttpClient, - Util.getUserAgent(context, "musikdroid"), - DefaultBandwidthMeter()) + audioStreamHttpClient, + Util.getUserAgent(context, "musikdroid"), + DefaultBandwidthMeter()) } else { this.datasources = DefaultDataSourceFactory( @@ -285,7 +283,7 @@ class ExoPlayerWrapper : PlayerWrapper() { } } - private var eventListener = object : ExoPlayer.EventListener { + private var eventListener = object : Player.EventListener { override fun onTimelineChanged(timeline: Timeline, manifest: Any?) { } @@ -341,7 +339,6 @@ class ExoPlayerWrapper : PlayerWrapper() { State.Playing, State.Paused -> state = State.Error - else -> { } } } @@ -351,10 +348,13 @@ class ExoPlayerWrapper : PlayerWrapper() { override fun onPlaybackParametersChanged(playbackParameters: PlaybackParameters) { } + + override fun onRepeatModeChanged(repeatMode: Int) { + } } companion object { - private var audioStreamHttpClient: OkHttpClient? = null + private lateinit var audioStreamHttpClient: OkHttpClient } init { diff --git a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/service/playback/impl/player/MediaPlayerWrapper.kt b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/service/playback/impl/player/MediaPlayerWrapper.kt index 10ad854b4..43bfccc3a 100644 --- a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/service/playback/impl/player/MediaPlayerWrapper.kt +++ b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/service/playback/impl/player/MediaPlayerWrapper.kt @@ -9,11 +9,11 @@ import android.os.PowerManager import android.util.Base64 import android.util.Log import io.casey.musikcube.remote.Application +import io.casey.musikcube.remote.service.websocket.model.ITrack import io.casey.musikcube.remote.service.playback.PlayerWrapper import io.casey.musikcube.remote.service.playback.impl.streaming.StreamProxy -import io.casey.musikcube.remote.service.websocket.model.ITrack -import io.casey.musikcube.remote.ui.settings.constants.Prefs import io.casey.musikcube.remote.util.Preconditions +import io.casey.musikcube.remote.ui.settings.constants.Prefs import java.io.IOException import java.util.* diff --git a/src/musikdroid/build.gradle b/src/musikdroid/build.gradle index bf95691d6..1021d09e1 100644 --- a/src/musikdroid/build.gradle +++ b/src/musikdroid/build.gradle @@ -7,7 +7,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:3.0.0' + classpath 'com.android.tools.build:gradle:3.0.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } }