Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audiobook Player Refactoring #992

Draft
wants to merge 10 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .ci-local/check-libraries.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ edu.umn.minitex.pdf:edu.umn.minitex.pdf.pdfviewer
org.librarysimplified.audiobook.audioengine:org.librarysimplified.audiobook.audioengine.core
org.librarysimplified.audiobook.overdrive:org.librarysimplified.audiobook.overdrive.main
org.librarysimplified.audiobook:org.librarysimplified.audiobook.api
org.librarysimplified.audiobook:org.librarysimplified.audiobook.downloads
org.librarysimplified.audiobook:org.librarysimplified.audiobook.player.api
org.librarysimplified.audiobook:org.librarysimplified.audiobook.feedbooks
org.librarysimplified.audiobook:org.librarysimplified.audiobook.http
org.librarysimplified.audiobook:org.librarysimplified.audiobook.license_check.api
Expand All @@ -110,10 +110,8 @@ org.librarysimplified.audiobook:org.librarysimplified.audiobook.manifest_fulfill
org.librarysimplified.audiobook:org.librarysimplified.audiobook.manifest_fulfill.spi
org.librarysimplified.audiobook:org.librarysimplified.audiobook.manifest_parser.api
org.librarysimplified.audiobook:org.librarysimplified.audiobook.manifest_parser.webpub
org.librarysimplified.audiobook:org.librarysimplified.audiobook.open_access
org.librarysimplified.audiobook:org.librarysimplified.audiobook.exoplayer
org.librarysimplified.audiobook:org.librarysimplified.audiobook.parser.api
org.librarysimplified.audiobook:org.librarysimplified.audiobook.rbdigital
org.librarysimplified.audiobook:org.librarysimplified.audiobook.views
org.librarysimplified.drm.axis:org.librarysimplified.drm.axis.provider
org.librarysimplified.drm:org.librarysimplified.drm.core
org.librarysimplified.http:org.librarysimplified.http.api
Expand Down
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
google()
}

ext.kotlin_version = "1.5.30"
ext.kotlin_version = "1.6.10"

dependencies {
classpath 'com.android.tools.build:gradle:7.0.2'
Expand All @@ -32,6 +32,7 @@ ext {
android_compile_sdk_version = 31
android_min_sdk_version = 24
android_target_sdk_version = 31
compose_kotlin_compiler_extension_version = "1.1.1"

// Required for some dependencies only available from our private S3
//
Expand Down
3 changes: 3 additions & 0 deletions build_aar.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ android {
kotlinOptions {
jvmTarget = "1.8"
}
composeOptions {
kotlinCompilerExtensionVersion compose_kotlin_compiler_extension_version
}

testOptions {
execution 'ANDROIDX_TEST_ORCHESTRATOR'
Expand Down
11 changes: 11 additions & 0 deletions simplified-app-openebooks/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,17 @@
android:label="@string/appName"
android:theme="@style/OEI_ActionBar"/>

<service
android:name="org.nypl.simplified.viewer.audiobook.AudioBookPlayerService"
android:enabled="true"
android:exported="true"
tools:ignore="ExportedService">

<intent-filter>
<action android:name="androidx.media2.session.MediaSessionService" />
</intent-filter>
</service>

<activity
android:name="org.nypl.simplified.cardcreator.CardCreatorActivity"
android:contentDescription="@string/appName"
Expand Down
11 changes: 11 additions & 0 deletions simplified-app-simplye/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,17 @@
android:label="@string/appName"
android:theme="@style/SimplyE_ActionBar"/>

<service
android:name="org.nypl.simplified.viewer.audiobook.AudioBookPlayerService"
android:enabled="true"
android:exported="true"
tools:ignore="ExportedService">

<intent-filter>
<action android:name="androidx.media2.session.MediaSessionService" />
</intent-filter>
</service>

<activity
android:name="org.nypl.simplified.cardcreator.CardCreatorActivity"
android:contentDescription="@string/appName"
Expand Down
11 changes: 11 additions & 0 deletions simplified-app-vanilla/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,17 @@
android:exported="false"
android:theme="@style/VanillaTheme_ActionBar"/>

<service
android:name="org.nypl.simplified.viewer.audiobook.AudioBookPlayerService"
android:enabled="true"
android:exported="true"
tools:ignore="ExportedService">

<intent-filter>
<action android:name="androidx.media2.session.MediaSessionService" />
</intent-filter>
</service>

<activity
android:name="org.nypl.simplified.cardcreator.CardCreatorActivity"
android:exported="false"
Expand Down
1 change: 0 additions & 1 deletion simplified-books-audio/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ dependencies {

implementation libs.kotlin.stdlib
implementation libs.kotlin.reflect
implementation libs.nypl.audiobook.downloads
implementation libs.nypl.audiobook.feedbooks
implementation libs.nypl.audiobook.manifest.fulfill.basic
implementation libs.nypl.audiobook.manifest.fulfill.opa
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ data class AudioBookManifestData(
val manifest: PlayerManifest,

/**
* The original fulfillmed manifest, suitable for writing to external storage.
* The original fulfilled manifest, suitable for writing to external storage.
*/

val fulfilled: ManifestFulfilled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@ package org.nypl.simplified.books.book_database
import com.fasterxml.jackson.databind.ObjectMapper
import net.jcip.annotations.GuardedBy
import one.irradia.mime.api.MIMEType
import org.librarysimplified.audiobook.api.PlayerAudioEngineRequest
import org.librarysimplified.audiobook.api.PlayerAudioEngines
import org.librarysimplified.audiobook.api.PlayerPosition
import org.librarysimplified.audiobook.api.PlayerPositions
import org.librarysimplified.audiobook.api.PlayerResult
import org.librarysimplified.audiobook.api.PlayerUserAgent
import org.librarysimplified.audiobook.manifest.api.PlayerManifest
import org.librarysimplified.audiobook.manifest_parser.api.ManifestParsers
import org.librarysimplified.audiobook.parser.api.ParseResult
Expand All @@ -25,7 +22,6 @@ import java.io.File
import java.io.FileInputStream
import java.io.FileNotFoundException
import java.io.IOException
import java.lang.IllegalStateException
import java.net.URI

/**
Expand Down Expand Up @@ -174,36 +170,6 @@ internal class DatabaseFormatHandleAudioBook internal constructor(

is ParseResult.Success -> {
this.log.debug("[{}]: selecting audio engine", briefID)

val engine =
PlayerAudioEngines.findBestFor(
PlayerAudioEngineRequest(
manifest = manifestResult.result,
filter = { true },
downloadProvider = NullDownloadProvider(),
userAgent = PlayerUserAgent("unused")
)
)

if (engine == null) {
throw UnsupportedOperationException(
"No audio engine is available to process the given request"
)
}

this.log.debug(
"[{}]: selected audio engine: {} {}",
briefID,
engine.engineProvider.name(),
engine.engineProvider.version()
)

when (val bookResult = engine.bookProvider.create(this.parameters.context)) {
is PlayerResult.Success -> bookResult.result.wholeBookDownloadTask.delete()
is PlayerResult.Failure -> throw bookResult.failure
}

this.log.debug("[{}]: deleted audio book data", briefID)
}
}
}
Expand Down

This file was deleted.

6 changes: 2 additions & 4 deletions simplified-tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,13 @@ dependencies {
api project(":simplified-webview")

api libs.nypl.audiobook.api
api libs.nypl.audiobook.downloads
api libs.nypl.audiobook.player.api
api libs.nypl.audiobook.feedbooks
api libs.nypl.audiobook.manifest.license.check.api
api libs.nypl.audiobook.manifest.fulfill.api
api libs.nypl.audiobook.manifest.fulfill.basic
api libs.nypl.audiobook.manifest.parser.webpub
api libs.nypl.audiobook.open.access
api libs.nypl.audiobook.rbdigital
api libs.nypl.audiobook.views
api libs.nypl.audiobook.exoplayer

implementation libs.io7m.jfunctional
implementation libs.io7m.jnull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import org.nypl.simplified.taskrecorder.api.TaskResult
import org.nypl.simplified.tests.MutableServiceDirectory
import org.nypl.simplified.tests.TestDirectories
import org.slf4j.LoggerFactory
import rx.Observable
import io.reactivex.Observable
import java.io.File
import java.net.URI

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package org.nypl.simplified.tests.mocking

import org.librarysimplified.audiobook.api.PlayerAudioBookProviderType
import org.librarysimplified.audiobook.api.PlayerAudioEngineProviderType
import org.librarysimplified.audiobook.api.PlayerAudioEngineRequest
import org.librarysimplified.audiobook.player.api.PlayerAudioEngineProviderType
import org.librarysimplified.audiobook.player.api.PlayerAudioEngineRequest
import org.librarysimplified.audiobook.api.PlayerVersion
import org.librarysimplified.audiobook.player.api.PlayerFactoryType
import org.slf4j.LoggerFactory

/**
Expand All @@ -22,7 +22,7 @@ class MockedAudioEngineProvider : PlayerAudioEngineProviderType {
return "mocked"
}

override fun tryRequest(request: PlayerAudioEngineRequest): PlayerAudioBookProviderType? {
override fun tryRequest(request: PlayerAudioEngineRequest): PlayerFactoryType? {
this.logger.debug("trying request: {}", request)

val next = onNextRequest
Expand All @@ -38,6 +38,6 @@ class MockedAudioEngineProvider : PlayerAudioEngineProviderType {

companion object {

var onNextRequest: ((PlayerAudioEngineRequest) -> PlayerAudioBookProviderType?)? = null
var onNextRequest: ((PlayerAudioEngineRequest) -> PlayerFactoryType?)? = null
}
}
42 changes: 34 additions & 8 deletions simplified-viewer-audiobook/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
android {
buildFeatures {
compose true
}
}

dependencies {
implementation project(":simplified-accounts-api")
implementation project(":simplified-books-api")
Expand All @@ -9,25 +15,45 @@ dependencies {
implementation project(":simplified-networkconnectivity-api")
implementation project(":simplified-profiles-controller-api")
implementation project(":simplified-services-api")
implementation project(":simplified-threads")
implementation project(":simplified-ui-screen")
implementation project(":simplified-ui-thread-api")
implementation project(":simplified-viewer-spi")

api libs.nypl.audiobook.api
api libs.nypl.audiobook.downloads
api libs.nypl.audiobook.player.api
api libs.nypl.audiobook.feedbooks
api libs.nypl.audiobook.manifest.license.check.api
api libs.nypl.audiobook.manifest.fulfill.api
api libs.nypl.audiobook.manifest.fulfill.basic
api libs.nypl.audiobook.manifest.parser.api
api libs.nypl.audiobook.manifest.parser.webpub
api libs.nypl.audiobook.open.access
api libs.nypl.audiobook.rbdigital
api libs.nypl.audiobook.views
api libs.nypl.audiobook.json.web.token
api libs.nypl.audiobook.exoplayer

implementation libs.r2.shared
implementation libs.r2.streamer
implementation libs.r2.navigator.media2

implementation libs.androidx.activity
implementation libs.androidx.app.compat
implementation libs.androidx.lifecycle.ext
implementation libs.kotlin.stdlib
implementation libs.kotlin.reflect
implementation libs.kotlin.coroutines

implementation libs.androidx.compose.runtime
implementation libs.androidx.compose.material
implementation libs.androidx.compose.animation
implementation libs.androidx.compose.tooling
implementation libs.androidx.activity.compose
implementation libs.androidx.lifecycle.viewmodel.compose

testImplementation libs.okhttp3.mockwebserver
testImplementation libs.junit
testImplementation libs.junit.jupiter.api
testImplementation libs.junit.jupiter.engine

androidTestImplementation libs.junit
androidTestImplementation libs.androidx.test.espresso.core
androidTestImplementation libs.androidx.test.ext.junit.ktx
androidTestImplementation libs.androidx.test.rules
androidTestImplementation libs.androidx.test.runner
androidTestImplementation libs.androidx.fragment.testing
}
Loading