summaryrefslogtreecommitdiffstats
path: root/airplay.py
diff options
context:
space:
mode:
Diffstat (limited to 'airplay.py')
-rw-r--r--airplay.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/airplay.py b/airplay.py
index dd3211d..0ffa75e 100644
--- a/airplay.py
+++ b/airplay.py
@@ -20,6 +20,7 @@
20# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21# DEALINGS IN THE SOFTWARE. 21# DEALINGS IN THE SOFTWARE.
22 22
23import gobject
23import totem 24import totem
24import platform 25import platform
25import time 26import time
@@ -56,7 +57,7 @@ class AirPlayTotemPlayer(AirPlayService):
56 # this must seek to a certain time 57 # this must seek to a certain time
57 def set_scrub(self, position): 58 def set_scrub(self, position):
58 if self.totem.is_seekable(): 59 if self.totem.is_seekable():
59 self.totem.action_seek_time(int(float(position) * 1000)) 60 gobject.idle_add(self.totem.action_seek_time, int(float(position) * 1000))
60 61
61 # this only sets the location and start position, it does not yet start to play 62 # this only sets the location and start position, it does not yet start to play
62 def play(self, location, position): 63 def play(self, location, position):
@@ -65,7 +66,7 @@ class AirPlayTotemPlayer(AirPlayService):
65 66
66 # stop the playback completely 67 # stop the playback completely
67 def stop(self, info): 68 def stop(self, info):
68 self.totem.action_stop() 69 gobject.idle_add(self.totem.action_stop)
69 70
70 # reverse HTTP to PTTH 71 # reverse HTTP to PTTH
71 def reverse(self, info): 72 def reverse(self, info):
@@ -75,13 +76,15 @@ class AirPlayTotemPlayer(AirPlayService):
75 def rate(self, speed): 76 def rate(self, speed):
76 if (int(float(speed)) >= 1): 77 if (int(float(speed)) >= 1):
77 if self.location is not None: 78 if self.location is not None:
79 timeout = 5
78 # start playback and loading of media 80 # start playback and loading of media
79 self.totem.add_to_playlist_and_play(self.location[0], "AirPlay Video", False) 81 gobject.idle_add(self.totem.add_to_playlist_and_play, self.location[0], "AirPlay Video", False)
80 # wait until stream-length is loaded and is not zero 82 # wait until stream-length is loaded and is not zero
81 duration = 0 83 duration = 0
82 while (int(duration) == 0): 84 while (int(duration) == 0 and timeout > 0):
83 duration = float(self.totem.get_property('stream-length') / 1000)
84 time.sleep(1) 85 time.sleep(1)
86 duration = float(self.totem.get_property('stream-length') / 1000)
87 timeout -= 1
85 # we also get a start time from the device 88 # we also get a start time from the device
86 targetoffset = float(duration * float(self.location[1])) 89 targetoffset = float(duration * float(self.location[1]))
87 position = float(self.totem.get_property('current-time') / 1000) 90 position = float(self.totem.get_property('current-time') / 1000)
@@ -90,10 +93,10 @@ class AirPlayTotemPlayer(AirPlayService):
90 self.set_scrub(targetoffset) 93 self.set_scrub(targetoffset)
91 94
92 if (not self.totem.is_playing()): 95 if (not self.totem.is_playing()):
93 self.totem.action_play() 96 gobject.idle_add(self.totem.action_play)
94 97
95 del self.location 98 del self.location
96 self.location = None 99 self.location = None
97 else: 100 else:
98 self.totem.action_pause() 101 gobject.idle_add(self.totem.action_pause)
99 102