mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
When starting smil audio jump to the first available audio element in the spine after the current item in case the current item has no smil elements
This commit is contained in:
parent
07d2ec3401
commit
8aa13dd2e7
@ -147,7 +147,7 @@ class ReadAudioEbook:
|
|||||||
self.play()
|
self.play()
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
spine_name, par = find_next_audio_in_spine(self.view.currently_showing.name, self.view.book.manifest)
|
spine_name, par = find_next_audio_in_spine(self.view.currently_showing.spine_index, self.view.book.manifest)
|
||||||
if spine_name:
|
if spine_name:
|
||||||
self.view.show_name(spine_name, initial_position={'type': 'smil_id', 'anchor': par.anchor})
|
self.view.show_name(spine_name, initial_position={'type': 'smil_id', 'anchor': par.anchor})
|
||||||
else:
|
else:
|
||||||
@ -188,7 +188,18 @@ class ReadAudioEbook:
|
|||||||
)
|
)
|
||||||
|
|
||||||
def start_playback(self):
|
def start_playback(self):
|
||||||
self.send_message('play')
|
cn = self.view.currently_showing.name
|
||||||
|
if self.view.book.manifest.files[cn]?.smil_map:
|
||||||
|
self.send_message('play')
|
||||||
|
else:
|
||||||
|
spine_name, par = find_next_audio_in_spine(self.view.currently_showing.spine_index, self.view.book.manifest)
|
||||||
|
if not spine_name:
|
||||||
|
spine_name, par = find_next_audio_in_spine(-1, self.view.book.manifest)
|
||||||
|
if spine_name:
|
||||||
|
self.view.show_name(spine_name, initial_position={'type': 'smil_id', 'anchor': par.anchor})
|
||||||
|
else:
|
||||||
|
self.hide()
|
||||||
|
error_dialog(_('No audio'), _('No audio found in this book'))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def container(self):
|
def container(self):
|
||||||
|
@ -81,10 +81,9 @@ def first_par(smil_map):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def find_next_audio_in_spine(current_name, book_manifest):
|
def find_next_audio_in_spine(spine_idx, book_manifest):
|
||||||
spine = book_manifest.spine
|
spine = book_manifest.spine
|
||||||
file_map = book_manifest.files
|
file_map = book_manifest.files
|
||||||
spine_idx = spine.indexOf(current_name)
|
|
||||||
|
|
||||||
for i in range(spine_idx + 1, spine.length):
|
for i in range(spine_idx + 1, spine.length):
|
||||||
q = spine[i]
|
q = spine[i]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user