Skip to content

Commit

Permalink
Added a bunch of debugging code to check on next chapter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Graham Van Heule committed Jan 27, 2024
1 parent 7a7577b commit f4a9121
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions cozy/control/mpris.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ def _on_app_setting_changed(self, event: str, _):

def _on_current_changed(self) -> None:
if not self._player.loaded_book:
print("mpris: book is not loaded")
return

self._metadata = self._get_new_metadata(self._player.loaded_book)
Expand Down
24 changes: 24 additions & 0 deletions cozy/media/gst_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,26 +125,43 @@ def init(self):
if self._player:
self.dispose()

print('init: test1')
self._player = Gst.ElementFactory.make("playbin", "player")
print('init: test2')
scaletempo = Gst.ElementFactory.make("scaletempo", "scaletempo")
print('init: test3')
scaletempo.sync_state_with_parent()

print('init: test4')
audiobin = Gst.ElementFactory.make("bin", "audiosink")
print('init: test5')
audiobin.add(scaletempo)
print('init: test6')

audiosink = Gst.ElementFactory.make("autoaudiosink", "audiosink")
print('init: test7')
audiobin.add(audiosink)
print('init: test8')

print('init: test9')
scaletempo.link(audiosink)
print('init: test10')
pad = scaletempo.get_static_pad("sink")
print('init: test11')
ghost_pad = Gst.GhostPad.new("sink", pad)
print('init: test12')
audiobin.add_pad(ghost_pad)
print('init: test13')

self._player.set_property("audio-sink", audiobin)
print('init: test14')

self._bus = self._player.get_bus()
print('init: test15')
self._bus.add_signal_watch()
print('init: test16')
self._bus_signal_id = self._bus.connect("message", self._on_gst_message)
print('init: test17')

def dispose(self):
if not self._player:
Expand All @@ -159,15 +176,22 @@ def dispose(self):
self.emit_event("dispose")

def load_file(self, path: str):
print('load_file: test1')
self.init()
print('load_file: test2')

if not os.path.exists(path):
raise FileNotFoundError()

print('load_file: test3')
self._player.set_property("uri", "file://" + path)
print('load_file: test4')
self._player.set_state(Gst.State.PAUSED)
print('load_file: test5')
self._player.set_property("volume", self._volume)
print('load_file: test6')
self._player.set_property("mute", False)
print('load_file: test7')

def play(self):
if not self._is_player_loaded() or self.state == GstPlayerState.PLAYING:
Expand Down
4 changes: 3 additions & 1 deletion cozy/media/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,13 @@ def _load_chapter(self, chapter: Chapter):
self._handle_file_not_found()
return

if file_changed or self._should_jump_to_chapter_position(chapter.position):
if file_changed or self._should_jump_to_chapter_position(chapter.position)
print("setting position to chapter position: " + str(chapter.position))
self._gst_player.position = chapter.position
self._gst_player.playback_speed = self._book.playback_speed

if file_changed or self._book.position != chapter.id:
print("setting book position to chapter id: " + str(chapter.id))
self._book.position = chapter.id
self.emit_event_main_thread("chapter-changed", self._book)

Expand Down

0 comments on commit f4a9121

Please sign in to comment.