mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2026-08-27 22:04:08 +02:00
Fix crash when server requests fail
This commit is contained in:
@@ -270,14 +270,18 @@ class MediaManager(var apiHandler: ApiHandler, var ctx: Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun play(libraryItemWrapper:LibraryItemWrapper, episode:PodcastEpisode?, playItemRequestPayload:PlayItemRequestPayload, cb: (PlaybackSession) -> Unit) {
|
fun play(libraryItemWrapper:LibraryItemWrapper, episode:PodcastEpisode?, playItemRequestPayload:PlayItemRequestPayload, cb: (PlaybackSession?) -> Unit) {
|
||||||
if (libraryItemWrapper is LocalLibraryItem) {
|
if (libraryItemWrapper is LocalLibraryItem) {
|
||||||
val localLibraryItem = libraryItemWrapper as LocalLibraryItem
|
val localLibraryItem = libraryItemWrapper as LocalLibraryItem
|
||||||
cb(localLibraryItem.getPlaybackSession(episode))
|
cb(localLibraryItem.getPlaybackSession(episode))
|
||||||
} else {
|
} else {
|
||||||
val libraryItem = libraryItemWrapper as LibraryItem
|
val libraryItem = libraryItemWrapper as LibraryItem
|
||||||
apiHandler.playLibraryItem(libraryItem.id,episode?.id ?: "",playItemRequestPayload) {
|
apiHandler.playLibraryItem(libraryItem.id,episode?.id ?: "",playItemRequestPayload) {
|
||||||
cb(it)
|
if (it == null) {
|
||||||
|
cb(null)
|
||||||
|
} else {
|
||||||
|
cb(it)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,9 +25,12 @@ class MediaSessionCallback(var playerNotificationService:PlayerNotificationServi
|
|||||||
Log.d(tag, "ON PREPARE MEDIA SESSION COMPAT")
|
Log.d(tag, "ON PREPARE MEDIA SESSION COMPAT")
|
||||||
playerNotificationService.mediaManager.getFirstItem()?.let { li ->
|
playerNotificationService.mediaManager.getFirstItem()?.let { li ->
|
||||||
playerNotificationService.mediaManager.play(li, null, playerNotificationService.getPlayItemRequestPayload(false)) {
|
playerNotificationService.mediaManager.play(li, null, playerNotificationService.getPlayItemRequestPayload(false)) {
|
||||||
Log.d(tag, "About to prepare player with ${it.displayTitle}")
|
if (it == null) {
|
||||||
Handler(Looper.getMainLooper()).post() {
|
Log.e(tag, "Failed to play library item")
|
||||||
playerNotificationService.preparePlayer(it,true,null)
|
} else {
|
||||||
|
Handler(Looper.getMainLooper()).post() {
|
||||||
|
playerNotificationService.preparePlayer(it,true,null)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -47,9 +50,12 @@ class MediaSessionCallback(var playerNotificationService:PlayerNotificationServi
|
|||||||
Log.d(tag, "ON PLAY FROM SEARCH $query")
|
Log.d(tag, "ON PLAY FROM SEARCH $query")
|
||||||
playerNotificationService.mediaManager.getFromSearch(query)?.let { li ->
|
playerNotificationService.mediaManager.getFromSearch(query)?.let { li ->
|
||||||
playerNotificationService.mediaManager.play(li, null, playerNotificationService.getPlayItemRequestPayload(false)) {
|
playerNotificationService.mediaManager.play(li, null, playerNotificationService.getPlayItemRequestPayload(false)) {
|
||||||
Log.d(tag, "About to prepare player with ${it.displayTitle}")
|
if (it == null) {
|
||||||
Handler(Looper.getMainLooper()).post() {
|
Log.e(tag, "Failed to play library item")
|
||||||
playerNotificationService.preparePlayer(it,true,null)
|
} else {
|
||||||
|
Handler(Looper.getMainLooper()).post() {
|
||||||
|
playerNotificationService.preparePlayer(it, true, null)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -105,9 +111,12 @@ class MediaSessionCallback(var playerNotificationService:PlayerNotificationServi
|
|||||||
|
|
||||||
libraryItemWrapper?.let { li ->
|
libraryItemWrapper?.let { li ->
|
||||||
playerNotificationService.mediaManager.play(li, podcastEpisode, playerNotificationService.getPlayItemRequestPayload(false)) {
|
playerNotificationService.mediaManager.play(li, podcastEpisode, playerNotificationService.getPlayItemRequestPayload(false)) {
|
||||||
Log.d(tag, "About to prepare player with ${it.displayTitle}")
|
if (it == null) {
|
||||||
Handler(Looper.getMainLooper()).post() {
|
Log.e(tag, "Failed to play library item")
|
||||||
playerNotificationService.preparePlayer(it,true,null)
|
} else {
|
||||||
|
Handler(Looper.getMainLooper()).post() {
|
||||||
|
playerNotificationService.preparePlayer(it, true, null)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+18
-8
@@ -31,8 +31,12 @@ class MediaSessionPlaybackPreparer(var playerNotificationService:PlayerNotificat
|
|||||||
Log.d(tag, "ON PREPARE $playWhenReady")
|
Log.d(tag, "ON PREPARE $playWhenReady")
|
||||||
playerNotificationService.mediaManager.getFirstItem()?.let { li ->
|
playerNotificationService.mediaManager.getFirstItem()?.let { li ->
|
||||||
playerNotificationService.mediaManager.play(li, null, playerNotificationService.getPlayItemRequestPayload(false)) {
|
playerNotificationService.mediaManager.play(li, null, playerNotificationService.getPlayItemRequestPayload(false)) {
|
||||||
Handler(Looper.getMainLooper()).post() {
|
if (it == null) {
|
||||||
playerNotificationService.preparePlayer(it,playWhenReady,null)
|
Log.e(tag, "Failed to play library item")
|
||||||
|
} else {
|
||||||
|
Handler(Looper.getMainLooper()).post() {
|
||||||
|
playerNotificationService.preparePlayer(it, playWhenReady, null)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -54,9 +58,12 @@ class MediaSessionPlaybackPreparer(var playerNotificationService:PlayerNotificat
|
|||||||
|
|
||||||
libraryItemWrapper?.let { li ->
|
libraryItemWrapper?.let { li ->
|
||||||
playerNotificationService.mediaManager.play(li, podcastEpisode, playerNotificationService.getPlayItemRequestPayload(false)) {
|
playerNotificationService.mediaManager.play(li, podcastEpisode, playerNotificationService.getPlayItemRequestPayload(false)) {
|
||||||
Log.d(tag, "About to prepare player with ${it.displayTitle}")
|
if (it == null) {
|
||||||
Handler(Looper.getMainLooper()).post() {
|
Log.e(tag, "Failed to play library item")
|
||||||
playerNotificationService.preparePlayer(it,playWhenReady,null)
|
} else {
|
||||||
|
Handler(Looper.getMainLooper()).post() {
|
||||||
|
playerNotificationService.preparePlayer(it, playWhenReady, null)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -66,9 +73,12 @@ class MediaSessionPlaybackPreparer(var playerNotificationService:PlayerNotificat
|
|||||||
Log.d(tag, "ON PREPARE FROM SEARCH $query")
|
Log.d(tag, "ON PREPARE FROM SEARCH $query")
|
||||||
playerNotificationService.mediaManager.getFromSearch(query)?.let { li ->
|
playerNotificationService.mediaManager.getFromSearch(query)?.let { li ->
|
||||||
playerNotificationService.mediaManager.play(li, null, playerNotificationService.getPlayItemRequestPayload(false)) {
|
playerNotificationService.mediaManager.play(li, null, playerNotificationService.getPlayItemRequestPayload(false)) {
|
||||||
Log.d(tag, "About to prepare player with ${it.displayTitle}")
|
if (it == null) {
|
||||||
Handler(Looper.getMainLooper()).post() {
|
Log.e(tag, "Failed to play library item")
|
||||||
playerNotificationService.preparePlayer(it,playWhenReady,null)
|
} else {
|
||||||
|
Handler(Looper.getMainLooper()).post() {
|
||||||
|
playerNotificationService.preparePlayer(it, playWhenReady, null)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-4
@@ -381,8 +381,13 @@ class PlayerNotificationService : MediaBrowserServiceCompat() {
|
|||||||
val libraryItemId = playbackSession.libraryItemId ?: "" // Must be true since direct play
|
val libraryItemId = playbackSession.libraryItemId ?: "" // Must be true since direct play
|
||||||
val episodeId = playbackSession.episodeId
|
val episodeId = playbackSession.episodeId
|
||||||
apiHandler.playLibraryItem(libraryItemId, episodeId, playItemRequestPayload) {
|
apiHandler.playLibraryItem(libraryItemId, episodeId, playItemRequestPayload) {
|
||||||
Handler(Looper.getMainLooper()).post {
|
if (it == null) { // Play request failed
|
||||||
preparePlayer(it, true, null)
|
clientEventEmitter?.onPlaybackFailed(errorMessage)
|
||||||
|
closePlayback()
|
||||||
|
} else {
|
||||||
|
Handler(Looper.getMainLooper()).post {
|
||||||
|
preparePlayer(it, true, null)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -400,8 +405,12 @@ class PlayerNotificationService : MediaBrowserServiceCompat() {
|
|||||||
val libraryItemId = playbackSession.libraryItemId ?: "" // Must be true since direct play
|
val libraryItemId = playbackSession.libraryItemId ?: "" // Must be true since direct play
|
||||||
val episodeId = playbackSession.episodeId
|
val episodeId = playbackSession.episodeId
|
||||||
apiHandler.playLibraryItem(libraryItemId, episodeId, playItemRequestPayload) {
|
apiHandler.playLibraryItem(libraryItemId, episodeId, playItemRequestPayload) {
|
||||||
Handler(Looper.getMainLooper()).post {
|
if (it == null) {
|
||||||
preparePlayer(it, true, null)
|
Log.e(tag, "Failed to start new playback session")
|
||||||
|
} else {
|
||||||
|
Handler(Looper.getMainLooper()).post {
|
||||||
|
preparePlayer(it, true, null)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ class AbsAudioPlayer : Plugin() {
|
|||||||
|
|
||||||
if (libraryItemId.isEmpty()) {
|
if (libraryItemId.isEmpty()) {
|
||||||
Log.e(tag, "Invalid call to play library item no library item id")
|
Log.e(tag, "Invalid call to play library item no library item id")
|
||||||
return call.resolve()
|
return call.resolve(JSObject("{\"error\":\"Invalid request\"}"))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (libraryItemId.startsWith("local")) { // Play local media item
|
if (libraryItemId.startsWith("local")) { // Play local media item
|
||||||
@@ -176,7 +176,7 @@ class AbsAudioPlayer : Plugin() {
|
|||||||
episode = podcastMedia.episodes?.find { ep -> ep.id == episodeId }
|
episode = podcastMedia.episodes?.find { ep -> ep.id == episodeId }
|
||||||
if (episode == null) {
|
if (episode == null) {
|
||||||
Log.e(tag, "prepareLibraryItem: Podcast episode not found $episodeId")
|
Log.e(tag, "prepareLibraryItem: Podcast episode not found $episodeId")
|
||||||
return call.resolve(JSObject())
|
return call.resolve(JSObject("{\"error\":\"Podcast episode not found\"}"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,13 +191,16 @@ class AbsAudioPlayer : Plugin() {
|
|||||||
val playItemRequestPayload = playerNotificationService.getPlayItemRequestPayload(false)
|
val playItemRequestPayload = playerNotificationService.getPlayItemRequestPayload(false)
|
||||||
|
|
||||||
apiHandler.playLibraryItem(libraryItemId, episodeId, playItemRequestPayload) {
|
apiHandler.playLibraryItem(libraryItemId, episodeId, playItemRequestPayload) {
|
||||||
|
if (it == null) {
|
||||||
|
call.resolve(JSObject("{\"error\":\"Server play request failed\"}"))
|
||||||
|
} else {
|
||||||
|
Handler(Looper.getMainLooper()).post {
|
||||||
|
Log.d(tag, "Preparing Player TEST ${jacksonMapper.writeValueAsString(it)}")
|
||||||
|
playerNotificationService.preparePlayer(it, playWhenReady, playbackRate)
|
||||||
|
}
|
||||||
|
|
||||||
Handler(Looper.getMainLooper()).post {
|
call.resolve(JSObject(jacksonMapper.writeValueAsString(it)))
|
||||||
Log.d(tag, "Preparing Player TEST ${jacksonMapper.writeValueAsString(it)}")
|
|
||||||
playerNotificationService.preparePlayer(it, playWhenReady, playbackRate)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
call.resolve(JSObject(jacksonMapper.writeValueAsString(it)))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,31 +143,35 @@ class AbsDownloader : Plugin() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
apiHandler.getLibraryItemWithProgress(libraryItemId, episodeId) { libraryItem ->
|
apiHandler.getLibraryItemWithProgress(libraryItemId, episodeId) { libraryItem ->
|
||||||
Log.d(tag, "Got library item from server ${libraryItem.id}")
|
if (libraryItem == null) {
|
||||||
|
call.resolve(JSObject("{\"error\":\"Server request failed\"}"))
|
||||||
|
} else {
|
||||||
|
Log.d(tag, "Got library item from server ${libraryItem.id}")
|
||||||
|
|
||||||
val localFolder = DeviceManager.dbManager.getLocalFolder(localFolderId)
|
val localFolder = DeviceManager.dbManager.getLocalFolder(localFolderId)
|
||||||
if (localFolder != null) {
|
if (localFolder != null) {
|
||||||
|
|
||||||
if (episodeId.isNotEmpty() && libraryItem.mediaType != "podcast") {
|
if (episodeId.isNotEmpty() && libraryItem.mediaType != "podcast") {
|
||||||
Log.e(tag, "Library item is not a podcast but episode was requested")
|
Log.e(tag, "Library item is not a podcast but episode was requested")
|
||||||
call.resolve(JSObject("{\"error\":\"Invalid library item not a podcast\"}"))
|
call.resolve(JSObject("{\"error\":\"Invalid library item not a podcast\"}"))
|
||||||
} else if (episodeId.isNotEmpty()) {
|
} else if (episodeId.isNotEmpty()) {
|
||||||
val podcast = libraryItem.media as Podcast
|
val podcast = libraryItem.media as Podcast
|
||||||
val episode = podcast.episodes?.find { podcastEpisode ->
|
val episode = podcast.episodes?.find { podcastEpisode ->
|
||||||
podcastEpisode.id == episodeId
|
podcastEpisode.id == episodeId
|
||||||
}
|
}
|
||||||
if (episode == null) {
|
if (episode == null) {
|
||||||
call.resolve(JSObject("{\"error\":\"Invalid podcast episode not found\"}"))
|
call.resolve(JSObject("{\"error\":\"Invalid podcast episode not found\"}"))
|
||||||
|
} else {
|
||||||
|
startLibraryItemDownload(libraryItem, localFolder, episode)
|
||||||
|
call.resolve()
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
startLibraryItemDownload(libraryItem, localFolder, episode)
|
startLibraryItemDownload(libraryItem, localFolder, null)
|
||||||
call.resolve()
|
call.resolve()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
startLibraryItemDownload(libraryItem, localFolder, null)
|
call.resolve(JSObject("{\"error\":\"Local Folder Not Found\"}"))
|
||||||
call.resolve()
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
call.resolve(JSObject("{\"error\":\"Local Folder Not Found\"}"))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -135,19 +135,29 @@ class ApiHandler(var ctx:Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getLibraryItem(libraryItemId:String, cb: (LibraryItem) -> Unit) {
|
fun getLibraryItem(libraryItemId:String, cb: (LibraryItem?) -> Unit) {
|
||||||
getRequest("/api/items/$libraryItemId?expanded=1", null, null) {
|
getRequest("/api/items/$libraryItemId?expanded=1", null, null) {
|
||||||
val libraryItem = jacksonMapper.readValue<LibraryItem>(it.toString())
|
if (it.has("error")) {
|
||||||
cb(libraryItem)
|
Log.e(tag, it.getString("error") ?: "getLibraryItem Failed")
|
||||||
|
cb(null)
|
||||||
|
} else {
|
||||||
|
val libraryItem = jacksonMapper.readValue<LibraryItem>(it.toString())
|
||||||
|
cb(libraryItem)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getLibraryItemWithProgress(libraryItemId:String, episodeId:String?, cb: (LibraryItem) -> Unit) {
|
fun getLibraryItemWithProgress(libraryItemId:String, episodeId:String?, cb: (LibraryItem?) -> Unit) {
|
||||||
var requestUrl = "/api/items/$libraryItemId?expanded=1&include=progress"
|
var requestUrl = "/api/items/$libraryItemId?expanded=1&include=progress"
|
||||||
if (!episodeId.isNullOrEmpty()) requestUrl += "&episode=$episodeId"
|
if (!episodeId.isNullOrEmpty()) requestUrl += "&episode=$episodeId"
|
||||||
getRequest(requestUrl, null, null) {
|
getRequest(requestUrl, null, null) {
|
||||||
val libraryItem = jacksonMapper.readValue<LibraryItem>(it.toString())
|
if (it.has("error")) {
|
||||||
cb(libraryItem)
|
Log.e(tag, it.getString("error") ?: "getLibraryItemWithProgress Failed")
|
||||||
|
cb(null)
|
||||||
|
} else {
|
||||||
|
val libraryItem = jacksonMapper.readValue<LibraryItem>(it.toString())
|
||||||
|
cb(libraryItem)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,15 +196,20 @@ class ApiHandler(var ctx:Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun playLibraryItem(libraryItemId:String, episodeId:String?, playItemRequestPayload:PlayItemRequestPayload, cb: (PlaybackSession) -> Unit) {
|
fun playLibraryItem(libraryItemId:String, episodeId:String?, playItemRequestPayload:PlayItemRequestPayload, cb: (PlaybackSession?) -> Unit) {
|
||||||
val payload = JSObject(jacksonMapper.writeValueAsString(playItemRequestPayload))
|
val payload = JSObject(jacksonMapper.writeValueAsString(playItemRequestPayload))
|
||||||
|
|
||||||
val endpoint = if (episodeId.isNullOrEmpty()) "/api/items/$libraryItemId/play" else "/api/items/$libraryItemId/play/$episodeId"
|
val endpoint = if (episodeId.isNullOrEmpty()) "/api/items/$libraryItemId/play" else "/api/items/$libraryItemId/play/$episodeId"
|
||||||
postRequest(endpoint, payload) {
|
postRequest(endpoint, payload) {
|
||||||
it.put("serverConnectionConfigId", DeviceManager.serverConnectionConfig?.id)
|
if (it.has("error")) {
|
||||||
it.put("serverAddress", DeviceManager.serverAddress)
|
Log.e(tag, it.getString("error") ?: "Play Library Item Failed")
|
||||||
val playbackSession = jacksonMapper.readValue<PlaybackSession>(it.toString())
|
cb(null)
|
||||||
cb(playbackSession)
|
} else {
|
||||||
|
it.put("serverConnectionConfigId", DeviceManager.serverConnectionConfig?.id)
|
||||||
|
it.put("serverAddress", DeviceManager.serverAddress)
|
||||||
|
val playbackSession = jacksonMapper.readValue<PlaybackSession>(it.toString())
|
||||||
|
cb(playbackSession)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,10 +251,12 @@ class ApiHandler(var ctx:Context) {
|
|||||||
Log.d(tag, "Sending sync local progress request with ${localMediaProgress.size} progress items")
|
Log.d(tag, "Sending sync local progress request with ${localMediaProgress.size} progress items")
|
||||||
val payload = JSObject(jacksonMapper.writeValueAsString(LocalMediaProgressSyncPayload(localMediaProgress)))
|
val payload = JSObject(jacksonMapper.writeValueAsString(LocalMediaProgressSyncPayload(localMediaProgress)))
|
||||||
postRequest("/api/me/sync-local-progress", payload) {
|
postRequest("/api/me/sync-local-progress", payload) {
|
||||||
Log.d(tag, "Media Progress Sync payload $payload - response ${it.toString()}")
|
Log.d(tag, "Media Progress Sync payload $payload - response ${it}")
|
||||||
|
|
||||||
if (it.toString() == "{}") {
|
if (it.toString() == "{}") {
|
||||||
Log.e(tag, "Progress sync received empty object")
|
Log.e(tag, "Progress sync received empty object")
|
||||||
|
} else if (it.has("error")) {
|
||||||
|
Log.e(tag, it.getString("error") ?: "Progress sync error")
|
||||||
} else {
|
} else {
|
||||||
val progressSyncResponsePayload = jacksonMapper.readValue<MediaProgressSyncResponsePayload>(it.toString())
|
val progressSyncResponsePayload = jacksonMapper.readValue<MediaProgressSyncResponsePayload>(it.toString())
|
||||||
|
|
||||||
|
|||||||
@@ -185,11 +185,17 @@ export default {
|
|||||||
}
|
}
|
||||||
AbsAudioPlayer.prepareLibraryItem({ libraryItemId, episodeId: null, playWhenReady: false, playbackRate })
|
AbsAudioPlayer.prepareLibraryItem({ libraryItemId, episodeId: null, playWhenReady: false, playbackRate })
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
console.log('Library item play response', JSON.stringify(data))
|
if (data.error) {
|
||||||
AbsAudioPlayer.requestSession()
|
const errorMsg = data.error || 'Failed to play'
|
||||||
|
this.$toast.error(errorMsg)
|
||||||
|
} else {
|
||||||
|
console.log('Library item play response', JSON.stringify(data))
|
||||||
|
AbsAudioPlayer.requestSession()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error('Failed', error)
|
console.error('Failed', error)
|
||||||
|
this.$toast.error('Failed to play')
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
async playLibraryItem(payload) {
|
async playLibraryItem(payload) {
|
||||||
@@ -220,15 +226,21 @@ export default {
|
|||||||
console.log('Called playLibraryItem', libraryItemId)
|
console.log('Called playLibraryItem', libraryItemId)
|
||||||
AbsAudioPlayer.prepareLibraryItem({ libraryItemId, episodeId, playWhenReady: true, playbackRate })
|
AbsAudioPlayer.prepareLibraryItem({ libraryItemId, episodeId, playWhenReady: true, playbackRate })
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
console.log('Library item play response', JSON.stringify(data))
|
if (data.error) {
|
||||||
if (!libraryItemId.startsWith('local')) {
|
const errorMsg = data.error || 'Failed to play'
|
||||||
this.serverLibraryItemId = libraryItemId
|
this.$toast.error(errorMsg)
|
||||||
} else {
|
} else {
|
||||||
this.serverLibraryItemId = serverLibraryItemId
|
console.log('Library item play response', JSON.stringify(data))
|
||||||
|
if (!libraryItemId.startsWith('local')) {
|
||||||
|
this.serverLibraryItemId = libraryItemId
|
||||||
|
} else {
|
||||||
|
this.serverLibraryItemId = serverLibraryItemId
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error('Failed', error)
|
console.error('Failed', error)
|
||||||
|
this.$toast.error('Failed to play')
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
pauseItem() {
|
pauseItem() {
|
||||||
|
|||||||
Reference in New Issue
Block a user