Fix local audio playback issue, update ffmpeg-kit to min version

This commit is contained in:
advplyr 2022-04-21 18:50:01 -05:00
parent 441bc24e2d
commit 9d6a467517
4 changed files with 17 additions and 10 deletions

View file

@ -29,7 +29,7 @@ android {
applicationId "com.audiobookshelf.app"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 69
versionCode 70
versionName "0.9.41-beta"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
aaptOptions {
@ -120,7 +120,7 @@ dependencies {
implementation 'com.fasterxml.jackson.module:jackson-module-kotlin:2.12.1'
// FFMPEG-Kit
implementation 'com.arthenica:ffmpeg-kit-full:4.5.1'
implementation 'com.arthenica:ffmpeg-kit-min:4.5.1'
}
apply from: 'capacitor.build.gradle'

View file

@ -104,7 +104,9 @@ class FolderScanner(var ctx: Context) {
var coverContentUrl:String? = null
var coverAbsolutePath:String? = null
var filesInFolder = itemFolder.search(false, DocumentFileType.FILE, arrayOf("audio/*", "image/*"))
// itemFolder.search(false, DocumentFileType.FILE, arrayOf("audio"))
var filesInFolder = itemFolder.search(false, DocumentFileType.FILE, arrayOf("audio/*", "image/*", "video/mp4"))
var existingLocalFilesRemoved = existingLocalFiles.filter { elf ->
filesInFolder.find { fif -> DeviceManager.getBase64Id(fif.id) == elf.id } == null // File was not found in media item folder
@ -117,7 +119,7 @@ class FolderScanner(var ctx: Context) {
filesInFolder.forEach { file ->
var mimeType = file.mimeType ?: ""
var filename = file.name ?: ""
var isAudio = mimeType.startsWith("audio")
var isAudio = mimeType.startsWith("audio") || mimeType == "video/mp4"
Log.d(tag, "Found $mimeType file $filename in folder $itemFolderName")
var localFileId = DeviceManager.getBase64Id(file.id)

View file

@ -309,16 +309,19 @@ class PlayerNotificationService : MediaBrowserServiceCompat() {
if (mPlayer == currentPlayer) {
var mediaSource:MediaSource
var dataSourceFactory = DefaultHttpDataSource.Factory()
dataSourceFactory.setUserAgent(channelId)
if (playbackSession.isLocal) {
Log.d(tag, "Playing Local Item")
var dataSourceFactory = DefaultDataSource.Factory(ctx)
mediaSource = ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(mediaItems[0])
} else if (!playbackSession.isHLS) {
Log.d(tag, "Direct Playing Item")
var dataSourceFactory = DefaultHttpDataSource.Factory()
dataSourceFactory.setUserAgent(channelId)
mediaSource = ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(mediaItems[0])
} else {
Log.d(tag, "Playing HLS Item")
var dataSourceFactory = DefaultHttpDataSource.Factory()
dataSourceFactory.setUserAgent(channelId)
dataSourceFactory.setDefaultRequestProperties(hashMapOf("Authorization" to "Bearer ${DeviceManager.token}"))
mediaSource = HlsMediaSource.Factory(dataSourceFactory).createMediaSource(mediaItems[0])
}

View file

@ -545,13 +545,15 @@ export default {
}
},
closePlayback() {
this.endPlayback()
AbsAudioPlayer.closePlayback()
},
endPlayback() {
this.$store.commit('setPlayerItem', null)
this.showFullscreen = false
this.isEnded = false
this.isLoading = false
this.playbackSession = null
AbsAudioPlayer.closePlayback()
},
//
// Listeners from audio AbsAudioPlayer
@ -607,13 +609,13 @@ export default {
},
onPlaybackClosed() {
console.log('Received onPlaybackClosed evt')
this.closePlayback()
this.endPlayback()
},
onPlaybackFailed(data) {
console.log('Received onPlaybackFailed evt')
var errorMessage = data.value || 'Unknown Error'
this.$toast.error(`Playback Failed: ${errorMessage}`)
this.closePlayback()
this.endPlayback()
},
async init() {
this.useChapterTrack = await this.$localStore.getUseChapterTrack()