mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-08-04 10:04:39 +02:00
Add:Android setting to use mp3 index seeking #638
This commit is contained in:
parent
4f03c2a35d
commit
9e7d1d1617
4 changed files with 52 additions and 5 deletions
|
@ -109,6 +109,7 @@ data class DeviceSettings(
|
|||
var enableAltView:Boolean,
|
||||
var jumpBackwardsTime:Int,
|
||||
var jumpForwardTime:Int,
|
||||
var enableMp3IndexSeeking:Boolean,
|
||||
var disableShakeToResetSleepTimer:Boolean,
|
||||
var shakeSensitivity: ShakeSensitivitySetting,
|
||||
var lockOrientation: LockOrientationSetting,
|
||||
|
@ -130,6 +131,7 @@ data class DeviceSettings(
|
|||
enableAltView = true,
|
||||
jumpBackwardsTime = 10,
|
||||
jumpForwardTime = 10,
|
||||
enableMp3IndexSeeking = false,
|
||||
disableShakeToResetSleepTimer = false,
|
||||
shakeSensitivity = ShakeSensitivitySetting.MEDIUM,
|
||||
lockOrientation = LockOrientationSetting.NONE,
|
||||
|
|
|
@ -43,6 +43,8 @@ import com.google.android.exoplayer2.audio.AudioAttributes
|
|||
import com.google.android.exoplayer2.ext.mediasession.MediaSessionConnector
|
||||
import com.google.android.exoplayer2.ext.mediasession.MediaSessionConnector.CustomActionProvider
|
||||
import com.google.android.exoplayer2.ext.mediasession.TimelineQueueNavigator
|
||||
import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory
|
||||
import com.google.android.exoplayer2.extractor.mp3.Mp3Extractor
|
||||
import com.google.android.exoplayer2.source.MediaSource
|
||||
import com.google.android.exoplayer2.source.ProgressiveMediaSource
|
||||
import com.google.android.exoplayer2.source.hls.HlsMediaSource
|
||||
|
@ -437,12 +439,26 @@ class PlayerNotificationService : MediaBrowserServiceCompat() {
|
|||
if (playbackSession.isLocal) {
|
||||
Log.d(tag, "Playing Local Item")
|
||||
val dataSourceFactory = DefaultDataSource.Factory(ctx)
|
||||
mediaSource = ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(mediaItems[0])
|
||||
|
||||
val extractorsFactory = DefaultExtractorsFactory()
|
||||
if (DeviceManager.deviceData.deviceSettings?.enableMp3IndexSeeking == true) {
|
||||
// @see https://exoplayer.dev/troubleshooting.html#why-is-seeking-inaccurate-in-some-mp3-files
|
||||
extractorsFactory.setMp3ExtractorFlags(Mp3Extractor.FLAG_ENABLE_INDEX_SEEKING)
|
||||
}
|
||||
|
||||
mediaSource = ProgressiveMediaSource.Factory(dataSourceFactory, extractorsFactory).createMediaSource(mediaItems[0])
|
||||
} else if (!playbackSession.isHLS) {
|
||||
Log.d(tag, "Direct Playing Item")
|
||||
val dataSourceFactory = DefaultHttpDataSource.Factory()
|
||||
|
||||
val extractorsFactory = DefaultExtractorsFactory()
|
||||
if (DeviceManager.deviceData.deviceSettings?.enableMp3IndexSeeking == true) {
|
||||
// @see https://exoplayer.dev/troubleshooting.html#why-is-seeking-inaccurate-in-some-mp3-files
|
||||
extractorsFactory.setMp3ExtractorFlags(Mp3Extractor.FLAG_ENABLE_INDEX_SEEKING)
|
||||
}
|
||||
|
||||
dataSourceFactory.setUserAgent(channelId)
|
||||
mediaSource = ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(mediaItems[0])
|
||||
mediaSource = ProgressiveMediaSource.Factory(dataSourceFactory, extractorsFactory).createMediaSource(mediaItems[0])
|
||||
} else {
|
||||
Log.d(tag, "Playing HLS Item")
|
||||
val dataSourceFactory = DefaultHttpDataSource.Factory()
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
"build": "nuxt build",
|
||||
"start": "nuxt start",
|
||||
"generate": "nuxt generate",
|
||||
"sync": "nuxt generate && npx cap sync",
|
||||
"icons-android": "cordova-res android --skip-config --copy",
|
||||
"ionic:build": "npm run build",
|
||||
"ionic:serve": "npm run start"
|
||||
|
@ -43,4 +44,4 @@
|
|||
"postcss": "^8.3.5",
|
||||
"tailwindcss": "^3.3.2"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -22,7 +22,7 @@
|
|||
</div>
|
||||
|
||||
<!-- Playback settings -->
|
||||
<p class="uppercase text-xs font-semibold text-gray-300 mb-2 mt-6">Playback Settings</p>
|
||||
<p class="uppercase text-xs font-semibold text-gray-300 mb-2 mt-10">Playback Settings</p>
|
||||
<div v-if="!isiOS" class="flex items-center py-3" @click="toggleDisableAutoRewind">
|
||||
<div class="w-10 flex justify-center">
|
||||
<ui-toggle-switch v-model="settings.disableAutoRewind" @input="saveSettings" />
|
||||
|
@ -41,10 +41,17 @@
|
|||
</div>
|
||||
<p class="pl-4">Jump forwards time</p>
|
||||
</div>
|
||||
<div v-if="!isiOS" class="flex items-center py-3" @click="toggleEnableMp3IndexSeeking">
|
||||
<div class="w-10 flex justify-center">
|
||||
<ui-toggle-switch v-model="settings.enableMp3IndexSeeking" @input="saveSettings" />
|
||||
</div>
|
||||
<p class="pl-4">Enable mp3 index seeking</p>
|
||||
<span class="material-icons-outlined ml-2" @click.stop="showConfirmMp3IndexSeeking">info</span>
|
||||
</div>
|
||||
|
||||
<!-- Sleep timer settings -->
|
||||
<template v-if="!isiOS">
|
||||
<p class="uppercase text-xs font-semibold text-gray-300 mb-2 mt-6">Sleep Timer Settings</p>
|
||||
<p class="uppercase text-xs font-semibold text-gray-300 mb-2 mt-10">Sleep Timer Settings</p>
|
||||
<div class="flex items-center py-3" @click="toggleDisableShakeToResetSleepTimer">
|
||||
<div class="w-10 flex justify-center">
|
||||
<ui-toggle-switch v-model="settings.disableShakeToResetSleepTimer" @input="saveSettings" />
|
||||
|
@ -131,6 +138,7 @@ export default {
|
|||
enableAltView: false,
|
||||
jumpForwardTime: 10,
|
||||
jumpBackwardsTime: 10,
|
||||
enableMp3IndexSeeking: false,
|
||||
disableShakeToResetSleepTimer: false,
|
||||
shakeSensitivity: 'MEDIUM',
|
||||
lockOrientation: 0,
|
||||
|
@ -165,6 +173,10 @@ export default {
|
|||
autoSleepTimerAutoRewind: {
|
||||
name: 'Enable sleep timer auto rewind',
|
||||
message: 'When the auto sleep timer finishes, playing the item again will automatically rewind your position.'
|
||||
},
|
||||
enableMp3IndexSeeking: {
|
||||
name: 'Enable mp3 index seeking',
|
||||
message: 'This setting should only be enabled if you have mp3 files that are not seeking correctly. Inaccurate seeking is most likely due to Variable birate (VBR) MP3 files. This setting will force index seeking, in which a time-to-byte mapping is built as the file is read. In some cases with large MP3 files there will be a delay when seeking towards the end of the file.'
|
||||
}
|
||||
},
|
||||
hapticFeedbackItems: [
|
||||
|
@ -315,6 +327,20 @@ export default {
|
|||
})
|
||||
}
|
||||
},
|
||||
async showConfirmMp3IndexSeeking() {
|
||||
const confirmResult = await Dialog.confirm({
|
||||
title: this.settingInfo.enableMp3IndexSeeking.name,
|
||||
message: this.settingInfo.enableMp3IndexSeeking.message,
|
||||
cancelButtonTitle: 'View More'
|
||||
})
|
||||
if (!confirmResult.value) {
|
||||
window.open('https://exoplayer.dev/troubleshooting.html#why-is-seeking-inaccurate-in-some-mp3-files', '_blank')
|
||||
}
|
||||
},
|
||||
toggleEnableMp3IndexSeeking() {
|
||||
this.settings.enableMp3IndexSeeking = !this.settings.enableMp3IndexSeeking
|
||||
this.saveSettings()
|
||||
},
|
||||
toggleAutoSleepTimer() {
|
||||
this.settings.autoSleepTimer = !this.settings.autoSleepTimer
|
||||
this.saveSettings()
|
||||
|
@ -388,6 +414,8 @@ export default {
|
|||
this.settings.enableAltView = !!deviceSettings.enableAltView
|
||||
this.settings.jumpForwardTime = deviceSettings.jumpForwardTime || 10
|
||||
this.settings.jumpBackwardsTime = deviceSettings.jumpBackwardsTime || 10
|
||||
this.settings.toggleEnableMp3IndexSeeking = !!deviceSettings.toggleEnableMp3IndexSeeking
|
||||
|
||||
this.settings.lockOrientation = deviceSettings.lockOrientation || 'NONE'
|
||||
this.lockCurrentOrientation = this.settings.lockOrientation !== 'NONE'
|
||||
this.settings.hapticFeedback = deviceSettings.hapticFeedback || 'LIGHT'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue