Upgraded to ExoPlayer 2.5.4 and Android Studio 3.0.1

This commit is contained in:
casey langen 2017-11-20 15:30:19 -08:00
parent 93f1980b77
commit a932c34b9d
4 changed files with 34 additions and 34 deletions

View File

@ -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'

View File

@ -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 {

View File

@ -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.*

View File

@ -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"
}
}