Skip to content

Commit

Permalink
Updated to work with new server with chapters
Browse files Browse the repository at this point in the history
  • Loading branch information
izderadicka committed Mar 9, 2019
1 parent c97d853 commit 7bc7259
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ android {
applicationId "eu.zderadicka.audioserve"
minSdkVersion 21
targetSdkVersion 28
versionCode 25
versionName "0.7.5"
versionCode 26
versionName "0.7.6"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/java/eu/zderadicka/audioserve/AudioService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import com.google.android.exoplayer2.decoder.DecoderCounters
import com.google.android.exoplayer2.ext.mediasession.DefaultPlaybackController
import com.google.android.exoplayer2.ext.mediasession.MediaSessionConnector
import com.google.android.exoplayer2.ext.mediasession.TimelineQueueNavigator
import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory
import com.google.android.exoplayer2.source.DynamicConcatenatingMediaSource
import com.google.android.exoplayer2.source.ExtractorMediaSource
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector
Expand Down Expand Up @@ -277,7 +278,10 @@ class AudioService : MediaBrowserServiceCompat() {
if (token != null) {
cm.startCacheLoader(token)
}
val extractorFactory = DefaultExtractorsFactory()
extractorFactory.setConstantBitrateSeekingEnabled(true)
sourceFactory = ExtractorMediaSource.Factory(cm.sourceFactory)
sourceFactory?.setExtractorsFactory(extractorFactory)

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,18 @@ private fun subfolderToItem(path:String): MediaBrowserCompat.MediaItem {
.build()
return MediaBrowserCompat.MediaItem(desc, MediaBrowserCompat.MediaItem.FLAG_BROWSABLE)
}

private val CHAPTER_RE = Regex("""\$\$[\d\-]+\$\$""")
private fun fileToItem(mediaId: String, cacheDir: File): MediaBrowserCompat.MediaItem? {
val fullFile = File(cacheDir,mediaId)
if (! fullFile.isFile()) return null

val extras = Bundle()
val f = File(mediaId)
val (name, ext) = splitExtension(f.name)
val normName = CHAPTER_RE.replace(name, "")
val descBuilder = MediaDescriptionCompat.Builder()
.setMediaId(mediaId)
.setTitle(name)
.setTitle(normName)
.setSubtitle(f.parent)
if (ext != null) {
extras.putString(METADATA_KEY_EXTENSION, ext)
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'
classpath 'com.android.tools.build:gradle:3.3.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
Expand Down

0 comments on commit 7bc7259

Please sign in to comment.