diff options
author | Martin Szulecki | 2010-12-28 14:44:59 +0100 |
---|---|---|
committer | Martin Szulecki | 2010-12-28 14:44:59 +0100 |
commit | 8c5a15b92ba7a1728a297bd948d4de0a78b85da4 (patch) | |
tree | cefa0300f505b8d56e1d1976066e9caeb37b10d0 | |
parent | 66dde69538809f66556324a24507cc49a34f8973 (diff) | |
download | totem-plugin-airplay-8c5a15b92ba7a1728a297bd948d4de0a78b85da4.tar.gz totem-plugin-airplay-8c5a15b92ba7a1728a297bd948d4de0a78b85da4.tar.bz2 |
Use gobject.idle_add() for actions to prevent Totem from crashing1.0.0
-rw-r--r-- | airplay.py | 17 |
1 files changed, 10 insertions, 7 deletions
@@ -20,6 +20,7 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. +import gobject import totem import platform import time @@ -56,7 +57,7 @@ class AirPlayTotemPlayer(AirPlayService): # this must seek to a certain time def set_scrub(self, position): if self.totem.is_seekable(): - self.totem.action_seek_time(int(float(position) * 1000)) + gobject.idle_add(self.totem.action_seek_time, int(float(position) * 1000)) # this only sets the location and start position, it does not yet start to play def play(self, location, position): @@ -65,7 +66,7 @@ class AirPlayTotemPlayer(AirPlayService): # stop the playback completely def stop(self, info): - self.totem.action_stop() + gobject.idle_add(self.totem.action_stop) # reverse HTTP to PTTH def reverse(self, info): @@ -75,13 +76,15 @@ class AirPlayTotemPlayer(AirPlayService): def rate(self, speed): if (int(float(speed)) >= 1): if self.location is not None: + timeout = 5 # start playback and loading of media - self.totem.add_to_playlist_and_play(self.location[0], "AirPlay Video", False) + gobject.idle_add(self.totem.add_to_playlist_and_play, self.location[0], "AirPlay Video", False) # wait until stream-length is loaded and is not zero duration = 0 - while (int(duration) == 0): - duration = float(self.totem.get_property('stream-length') / 1000) + while (int(duration) == 0 and timeout > 0): time.sleep(1) + duration = float(self.totem.get_property('stream-length') / 1000) + timeout -= 1 # we also get a start time from the device targetoffset = float(duration * float(self.location[1])) position = float(self.totem.get_property('current-time') / 1000) @@ -90,10 +93,10 @@ class AirPlayTotemPlayer(AirPlayService): self.set_scrub(targetoffset) if (not self.totem.is_playing()): - self.totem.action_play() + gobject.idle_add(self.totem.action_play) del self.location self.location = None else: - self.totem.action_pause() + gobject.idle_add(self.totem.action_pause) |