6d1a6cb3ad2b61c8c417a85ead564d8bf58c3dda
Stefan Schuermans initial PyGtk window

Stefan Schuermans authored 10 years ago

sync_gui.py         1) #! /usr/bin/env python
sync_gui.py         2) 
Stefan Schuermans comments by ST

Stefan Schuermans authored 10 years ago

stage_director.py   3) # BlinkenArea Stage Director
Stefan Schuermans add copyright, remove statu...

Stefan Schuermans authored 10 years ago

sync_gui.py         4) # Copyright 2013 Stefan Schuermans <stefan@blinkenarea.org>
sync_gui.py         5) # Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html
sync_gui.py         6) # a blinkenarea.org project - https://www.blinkenarea.org/
sync_gui.py         7) 
Stefan Schuermans initial PyGtk window

Stefan Schuermans authored 10 years ago

sync_gui.py         8) import os
sync_gui.py         9) from gi.repository import Gtk
Stefan Schuermans start making player work -...

Stefan Schuermans authored 10 years ago

sync_gui.py        10) import gobject
Stefan Schuermans show current playlist item...

Stefan Schuermans authored 10 years ago

sync_gui.py        11) import pango
Stefan Schuermans implement UDP sync protocol...

Stefan Schuermans authored 10 years ago

sync_gui.py        12) import socket
sync_gui.py        13) import struct
Stefan Schuermans add menu, implement file open

Stefan Schuermans authored 10 years ago

sync_gui.py        14) import sys
Stefan Schuermans start making player work -...

Stefan Schuermans authored 10 years ago

sync_gui.py        15) import time
Stefan Schuermans reading playlist

Stefan Schuermans authored 10 years ago

sync_gui.py        16) import playlist
Stefan Schuermans show current position as h:...

Stefan Schuermans authored 10 years ago

sync_gui.py        17) import time_fmt
sync_gui.py        18) 
Stefan Schuermans initial PyGtk window

Stefan Schuermans authored 10 years ago

sync_gui.py        19) scriptdir = os.path.dirname(os.path.abspath(__file__))
sync_gui.py        20) 
sync_gui.py        21) class SyncGui:
Stefan Schuermans start making player work -...

Stefan Schuermans authored 10 years ago

sync_gui.py        22) 
Stefan Schuermans initial PyGtk window

Stefan Schuermans authored 10 years ago

sync_gui.py        23)   def __init__(self):
Stefan Schuermans start making player work -...

Stefan Schuermans authored 10 years ago

sync_gui.py        24)     """construct a SyncGui object"""
Stefan Schuermans initial PyGtk window

Stefan Schuermans authored 10 years ago

sync_gui.py        25)     self.builder = Gtk.Builder()
Stefan Schuermans comments by ST

Stefan Schuermans authored 10 years ago

stage_director.py  26)     self.builder.add_from_file(scriptdir + "/stage_director.glade")
Stefan Schuermans add menu, implement file open

Stefan Schuermans authored 10 years ago

sync_gui.py        27)     self.widMainWindow = self.builder.get_object("MainWindow")
Stefan Schuermans start making player work -...

Stefan Schuermans authored 10 years ago

sync_gui.py        28)     self.widPlaylistView = self.builder.get_object("PlaylistView")
sync_gui.py        29)     self.widPlaylistStore = self.builder.get_object("PlaylistStore")
sync_gui.py        30)     self.widPosition = self.builder.get_object("Position")
sync_gui.py        31)     self.widPositionScale = self.builder.get_object("PositionScale")
sync_gui.py        32)     self.widPositionAt = self.builder.get_object("PositionAt")
sync_gui.py        33)     self.widPositionRemaining = self.builder.get_object("PositionRemaining")
sync_gui.py        34)     self.widBtnPlay = self.builder.get_object("Play")
Stefan Schuermans comments by ST

Stefan Schuermans authored 10 years ago

stage_director.py  35)     self.widBtnPause = self.builder.get_object("Pause")
Stefan Schuermans use second bulb to display...

Stefan Schuermans authored 10 years ago

sync_gui.py        36)     self.widLogoStop = self.builder.get_object("LogoStop")
sync_gui.py        37)     self.widLogoPlay = self.builder.get_object("LogoPlay")
sync_gui.py        38)     self.widLogoUdpErr = self.builder.get_object("LogoUdpErr")
sync_gui.py        39)     self.widLogoUdpOk = self.builder.get_object("LogoUdpOk")
Stefan Schuermans implement UDP output and de...

Stefan Schuermans authored 10 years ago

sync_gui.py        40)     self.widStatus = self.builder.get_object("Status")
Stefan Schuermans initial PyGtk window

Stefan Schuermans authored 10 years ago

sync_gui.py        41)     handlers = {
Stefan Schuermans implement UDP output and de...

Stefan Schuermans authored 10 years ago

sync_gui.py        42)       "onDestroy":           self.onDestroy,
sync_gui.py        43)       "onFileOpen":          self.onFileOpen,
sync_gui.py        44)       "onFileExit":          self.onFileExit,
sync_gui.py        45)       "onExtrasDestination": self.onExtrasDestination,
Stefan Schuermans comments by ST

Stefan Schuermans authored 10 years ago

stage_director.py  46)       "onExtrasAbout":       self.onExtrasAbout,
Stefan Schuermans implement UDP output and de...

Stefan Schuermans authored 10 years ago

sync_gui.py        47)       "onPlaylistDblClick":  self.onPlaylistDblClick,
sync_gui.py        48)       "onNewPosition":       self.onNewPosition,
sync_gui.py        49)       "onPrevious":          self.onPrevious,
sync_gui.py        50)       "onPlay":              self.onPlay,
Stefan Schuermans comments by ST

Stefan Schuermans authored 10 years ago

stage_director.py  51)       "onPause":             self.onPause,
stage_director.py  52)       "onStop":              self.onStop,
Stefan Schuermans implement UDP output and de...

Stefan Schuermans authored 10 years ago

sync_gui.py        53)       "onNext":              self.onNext,
Stefan Schuermans initial PyGtk window

Stefan Schuermans authored 10 years ago

sync_gui.py        54)     }
sync_gui.py        55)     self.builder.connect_signals(handlers)
Stefan Schuermans reading playlist

Stefan Schuermans authored 10 years ago

sync_gui.py        56)     self.playlist = playlist.Playlist()
Stefan Schuermans add menu, implement file open

Stefan Schuermans authored 10 years ago

sync_gui.py        57)     if len(sys.argv) >= 2: # load initial playlist from command line
sync_gui.py        58)       self.playlist.read(sys.argv[1])
Stefan Schuermans start making player work -...

Stefan Schuermans authored 10 years ago

sync_gui.py        59)     self.playlist.update(self.widPlaylistStore)
Stefan Schuermans implement UDP output and de...

Stefan Schuermans authored 10 years ago

sync_gui.py        60)     self.sock = None
Stefan Schuermans start making player work -...

Stefan Schuermans authored 10 years ago

sync_gui.py        61)     self.stEntryIdx = -1 # no entry selected
sync_gui.py        62)     self.stName = "" # no current entry name
sync_gui.py        63)     self.stDuration = 0 # current entry has zero size
sync_gui.py        64)     self.stPosition = 0 # at begin of current entry
sync_gui.py        65)     self.stPlaying = False # not playing
Stefan Schuermans implement UDP output and de...

Stefan Schuermans authored 10 years ago

sync_gui.py        66)     self.stDestination = "255.255.255.255" # local LAN broadcast by default
sync_gui.py        67)     self.setupSock()
Stefan Schuermans show current playlist item...

Stefan Schuermans authored 10 years ago

sync_gui.py        68)     self.updateEntry()
Stefan Schuermans start making player work -...

Stefan Schuermans authored 10 years ago

sync_gui.py        69)     self.updateButtonVisibility()
Stefan Schuermans implement UDP output and de...

Stefan Schuermans authored 10 years ago

sync_gui.py        70)     gobject.timeout_add(10, self.onTimer10ms)
sync_gui.py        71)     gobject.timeout_add(100, self.onTimer100ms)
Stefan Schuermans show current position as h:...

Stefan Schuermans authored 10 years ago

sync_gui.py        72) 
Stefan Schuermans start making player work -...

Stefan Schuermans authored 10 years ago

sync_gui.py        73)   def showPosition(self):
sync_gui.py        74)     """update the position texts next to the position slider"""
sync_gui.py        75)     # format current time and remaining time
sync_gui.py        76)     posAt = time_fmt.sec2str(self.stPosition)
sync_gui.py        77)     posRemaining = time_fmt.sec2str(self.stDuration - self.stPosition)
sync_gui.py        78)     self.widPositionAt.set_text(posAt)
sync_gui.py        79)     self.widPositionRemaining.set_text(posRemaining)
sync_gui.py        80) 
sync_gui.py        81)   def updatePositionState(self):
sync_gui.py        82)     """update the position in the state, but not the slider"""
sync_gui.py        83)     # calculate (virtual) start time of playing
sync_gui.py        84)     # i.e. the time the playing would have had started to arrive at the
sync_gui.py        85)     # current position now if it had played continuosly
sync_gui.py        86)     self.stPlayStart = time.time() - self.stPosition
sync_gui.py        87)     # update position texts
sync_gui.py        88)     self.showPosition()
sync_gui.py        89) 
sync_gui.py        90)   def updatePosition(self):
sync_gui.py        91)     """update the position including the position slider"""
sync_gui.py        92)     # update GUI slider
sync_gui.py        93)     self.widPositionScale.set_value(self.stPosition)
sync_gui.py        94)     # update position state
sync_gui.py        95)     self.updatePositionState()
sync_gui.py        96) 
sync_gui.py        97)   def updateDuration(self):
sync_gui.py        98)     """update the duration (i.e. range for the slider) based on the current
sync_gui.py        99)        playlist entry"""
sync_gui.py       100)     # get duration of new playlist entry
sync_gui.py       101)     self.stDuration = 0
sync_gui.py       102)     if self.stEntryIdx >= 0:
sync_gui.py       103)       entry = self.playlist.entries[self.stEntryIdx]
sync_gui.py       104)       if entry["type"] == "normal":
sync_gui.py       105)         self.stDuration = entry["duration"]
sync_gui.py       106)     # set position to begin
sync_gui.py       107)     self.stPosition = 0
sync_gui.py       108)     # update value range
sync_gui.py       109)     self.widPosition.set_upper(self.stDuration)
sync_gui.py       110)     # update position of slider
sync_gui.py       111)     self.updatePosition()
sync_gui.py       112) 
Stefan Schuermans show current playlist item...

Stefan Schuermans authored 10 years ago

sync_gui.py       113)   def updateEntry(self):
sync_gui.py       114)     """update current entry of playlist and duration, position, ..."""
Stefan Schuermans remove forward and backward...

Stefan Schuermans authored 10 years ago

sync_gui.py       115)     # clear selection of playlist
sync_gui.py       116)     sel = self.widPlaylistView.get_selection()
sync_gui.py       117)     if sel:
sync_gui.py       118)       sel.unselect_all()
Stefan Schuermans show current playlist item...

Stefan Schuermans authored 10 years ago

sync_gui.py       119)     # sanity check for entry index
sync_gui.py       120)     if self.stEntryIdx < -1 or self.stEntryIdx >= len(self.playlist.entries):
sync_gui.py       121)       self.stEntryIdx = -1
Stefan Schuermans add menu, implement file open

Stefan Schuermans authored 10 years ago

sync_gui.py       122)     # get name of current entry
sync_gui.py       123)     self.stName = ""
sync_gui.py       124)     if self.stEntryIdx >= 0 and \
sync_gui.py       125)        self.playlist.entries[self.stEntryIdx]["type"] == "normal":
sync_gui.py       126)       self.stName = self.playlist.entries[self.stEntryIdx]["name"]
Stefan Schuermans show current playlist item...

Stefan Schuermans authored 10 years ago

sync_gui.py       127)     # make current entry bold, all others non-bold
sync_gui.py       128)     def update(model, path, it, user_data):
sync_gui.py       129)       (idx,) = model.get(it, 0)
sync_gui.py       130)       if idx == self.stEntryIdx:
sync_gui.py       131)         weight = pango.WEIGHT_BOLD
sync_gui.py       132)       else:
sync_gui.py       133)         weight = pango.WEIGHT_NORMAL
sync_gui.py       134)       model.set(it, 1, weight)
sync_gui.py       135)     self.widPlaylistStore.foreach(update, None)
Stefan Schuermans remove forward and backward...

Stefan Schuermans authored 10 years ago

sync_gui.py       136)     # playing and (no entry or stop entry)
sync_gui.py       137)     # -> stop playing and update button visibility
sync_gui.py       138)     if self.stPlaying and (self.stEntryIdx < 0 or \
sync_gui.py       139)        self.playlist.entries[self.stEntryIdx]["type"] == "stop"):
sync_gui.py       140)       self.stPlaying = False
sync_gui.py       141)       self.updateButtonVisibility()
Stefan Schuermans show current playlist item...

Stefan Schuermans authored 10 years ago

sync_gui.py       142)     # update duration, position, ...
sync_gui.py       143)     self.updateDuration()
sync_gui.py       144) 
Stefan Schuermans start making player work -...

Stefan Schuermans authored 10 years ago

sync_gui.py       145)   def updateButtonVisibility(self):
sync_gui.py       146)     """update the visibility of the buttons based on if playing or not"""
sync_gui.py       147)     self.widBtnPlay.set_visible(not self.stPlaying)
Stefan Schuermans comments by ST

Stefan Schuermans authored 10 years ago

stage_director.py 148)     self.widBtnPause.set_visible(self.stPlaying)
Stefan Schuermans use second bulb to display...

Stefan Schuermans authored 10 years ago

sync_gui.py       149)     self.widLogoStop.set_visible(not self.stPlaying)
sync_gui.py       150)     self.widLogoPlay.set_visible(self.stPlaying)
Stefan Schuermans initial PyGtk window

Stefan Schuermans authored 10 years ago

sync_gui.py       151) 
Stefan Schuermans implement UDP output and de...

Stefan Schuermans authored 10 years ago

sync_gui.py       152)   def closeSock(self):
sync_gui.py       153)     """close UDP socket"""
Stefan Schuermans use second bulb to display...

Stefan Schuermans authored 10 years ago

sync_gui.py       154)     self.widLogoUdpErr.set_visible(True)
sync_gui.py       155)     self.widLogoUdpOk.set_visible(False)
Stefan Schuermans implement UDP output and de...

Stefan Schuermans authored 10 years ago

sync_gui.py       156)     self.widStatus.remove_all(0)
sync_gui.py       157)     self.widStatus.push(0, "UDP output ERROR")
sync_gui.py       158)     if self.sock is not None:
sync_gui.py       159)       self.sock.close()
sync_gui.py       160)     self.sock = None
sync_gui.py       161) 
sync_gui.py       162)   def setupSock(self):
sync_gui.py       163)     """create a new UDP socket and "connect" it to the destination address"""
sync_gui.py       164)     self.closeSock()
sync_gui.py       165)     try:
sync_gui.py       166)       self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sync_gui.py       167)       self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
sync_gui.py       168)       self.sock.connect((self.stDestination, 5740))
sync_gui.py       169)       self.widStatus.remove_all(0)
sync_gui.py       170)       self.widStatus.push(0, "UDP output to \"" + self.stDestination +
sync_gui.py       171)                              "\" port 5740")
Stefan Schuermans use second bulb to display...

Stefan Schuermans authored 10 years ago

sync_gui.py       172)       self.widLogoUdpErr.set_visible(False)
sync_gui.py       173)       self.widLogoUdpOk.set_visible(True)
Stefan Schuermans implement UDP output and de...

Stefan Schuermans authored 10 years ago

sync_gui.py       174)     except:
sync_gui.py       175)       self.closeSock()
sync_gui.py       176) 
Stefan Schuermans initial PyGtk window

Stefan Schuermans authored 10 years ago

sync_gui.py       177)   def onDestroy(self, widget):
Stefan Schuermans start making player work -...

Stefan Schuermans authored 10 years ago

sync_gui.py       178)     """window will be destroyed"""
Stefan Schuermans initial PyGtk window

Stefan Schuermans authored 10 years ago

sync_gui.py       179)     Gtk.main_quit()
sync_gui.py       180) 
Stefan Schuermans add menu, implement file open

Stefan Schuermans authored 10 years ago

sync_gui.py       181)   def onFileOpen(self, widget):
sync_gui.py       182)     """File Open clicked in menu"""
Stefan Schuermans comments by ST

Stefan Schuermans authored 10 years ago

stage_director.py 183)     #print("DEBUG stage_director File Open")
Stefan Schuermans implement UDP output and de...

Stefan Schuermans authored 10 years ago

sync_gui.py       184)     # create and run file chooser dialog
sync_gui.py       185)     dialog = Gtk.FileChooserDialog(
Stefan Schuermans comments by ST

Stefan Schuermans authored 10 years ago

stage_director.py 186)       "BlinkenArea Stage Director - File Open...",
Stefan Schuermans implement UDP output and de...

Stefan Schuermans authored 10 years ago

sync_gui.py       187)       self.widMainWindow, Gtk.FileChooserAction.OPEN,
sync_gui.py       188)       (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
sync_gui.py       189)        Gtk.STOCK_OPEN, Gtk.ResponseType.OK))
Stefan Schuermans add menu, implement file open

Stefan Schuermans authored 10 years ago

sync_gui.py       190)     dialog.set_default_response(Gtk.ResponseType.OK)
sync_gui.py       191)     filt = Gtk.FileFilter()
sync_gui.py       192)     filt.set_name("All files")
sync_gui.py       193)     filt.add_pattern("*")
sync_gui.py       194)     dialog.add_filter(filt)
sync_gui.py       195)     response = dialog.run()
sync_gui.py       196)     if response == Gtk.ResponseType.OK:
sync_gui.py       197)       # dialog closed with OK -> load new playlist
sync_gui.py       198)       filename = dialog.get_filename()
sync_gui.py       199)       self.playlist.read(filename)
sync_gui.py       200)       self.playlist.update(self.widPlaylistStore)
sync_gui.py       201)       self.stEntryIdx = -1 # no entry selected
sync_gui.py       202)       self.stPlaying = False # not playing
sync_gui.py       203)       self.updateEntry()
sync_gui.py       204)       self.updateButtonVisibility()
Stefan Schuermans implement UDP output and de...

Stefan Schuermans authored 10 years ago

sync_gui.py       205)     # clean up
Stefan Schuermans add menu, implement file open

Stefan Schuermans authored 10 years ago

sync_gui.py       206)     dialog.destroy()
sync_gui.py       207) 
sync_gui.py       208)   def onFileExit(self, widget):
sync_gui.py       209)     """File Exit clicked in menu"""
Stefan Schuermans comments by ST

Stefan Schuermans authored 10 years ago

stage_director.py 210)     #print("DEBUG stage_director File Exit")
Stefan Schuermans add menu, implement file open

Stefan Schuermans authored 10 years ago

sync_gui.py       211)     Gtk.main_quit()
sync_gui.py       212) 
Stefan Schuermans implement UDP output and de...

Stefan Schuermans authored 10 years ago

sync_gui.py       213)   def onExtrasDestination(self, widget):
sync_gui.py       214)     """Extras Destination Address clicked in menu"""
Stefan Schuermans comments by ST

Stefan Schuermans authored 10 years ago

stage_director.py 215)     #print("DEBUG stage_director Extras Destination")
Stefan Schuermans implement UDP output and de...

Stefan Schuermans authored 10 years ago

sync_gui.py       216)     # run input dialog to ask for new destination
sync_gui.py       217)     dialog = self.builder.get_object("DialogDestination")
sync_gui.py       218)     cur = self.builder.get_object("DiaDestCur")
sync_gui.py       219)     new = self.builder.get_object("DiaDestNew")
sync_gui.py       220)     cur.set_text(self.stDestination)
sync_gui.py       221)     new.set_text(self.stDestination)
sync_gui.py       222)     response = dialog.run()
sync_gui.py       223)     if response == 1:
sync_gui.py       224)       self.stDestination = new.get_text()
sync_gui.py       225)     # hide input dialog
sync_gui.py       226)     dialog.hide()
sync_gui.py       227)     # re-create UDP socket
sync_gui.py       228)     self.setupSock()
sync_gui.py       229) 
Stefan Schuermans comments by ST

Stefan Schuermans authored 10 years ago

stage_director.py 230)   def onExtrasAbout(self, widget):
stage_director.py 231)     """Extras About clicked in menu"""
stage_director.py 232)     #print("DEBUG stage_director Extras About")
stage_director.py 233)     # run about dialog
stage_director.py 234)     dialog = self.builder.get_object("DialogAbout")
stage_director.py 235)     dialog.run()
stage_director.py 236)     dialog.hide()
stage_director.py 237) 
Stefan Schuermans start making player work -...

Stefan Schuermans authored 10 years ago

sync_gui.py       238)   def onPlaylistDblClick(self, widget, row, col):
sync_gui.py       239)     """playlist entry has been double-clicked"""
sync_gui.py       240)     # get index of selected entry
sync_gui.py       241)     idx = -1
sync_gui.py       242)     sel = self.widPlaylistView.get_selection()
sync_gui.py       243)     if sel is not None:
sync_gui.py       244)       (model, it) = sel.get_selected()
sync_gui.py       245)       if it is not None:
Stefan Schuermans show current playlist item...

Stefan Schuermans authored 10 years ago

sync_gui.py       246)         (idx,) = model.get(it, 0)
Stefan Schuermans comments by ST

Stefan Schuermans authored 10 years ago

stage_director.py 247)     #print("DEBUG stage_director playlist double-click idx=%d" % (idx))
Stefan Schuermans start making player work -...

Stefan Schuermans authored 10 years ago

sync_gui.py       248)     # update playlist entry
sync_gui.py       249)     self.stEntryIdx = idx
Stefan Schuermans remove forward and backward...

Stefan Schuermans authored 10 years ago

sync_gui.py       250)     # set position to zero if playing
sync_gui.py       251)     if self.stPlaying:
sync_gui.py       252)       self.stPosition = 0
Stefan Schuermans show current playlist item...

Stefan Schuermans authored 10 years ago

sync_gui.py       253)     # update entry
sync_gui.py       254)     self.updateEntry()
Stefan Schuermans start making player work -...

Stefan Schuermans authored 10 years ago

sync_gui.py       255) 
Stefan Schuermans show current position as h:...

Stefan Schuermans authored 10 years ago

sync_gui.py       256)   def onNewPosition(self, widget, scroll, value):
Stefan Schuermans start making player work -...

Stefan Schuermans authored 10 years ago

sync_gui.py       257)     """slider has been moved to a new position"""
Stefan Schuermans comments by ST

Stefan Schuermans authored 10 years ago

stage_director.py 258)     #print("DEBUG stage_director new position " + str(value));
Stefan Schuermans start making player work -...

Stefan Schuermans authored 10 years ago

sync_gui.py       259)     # clamp position to valid range
sync_gui.py       260)     if value < 0:
sync_gui.py       261)       value = 0
sync_gui.py       262)     if value > self.stDuration:
sync_gui.py       263)       value = self.stDuration
sync_gui.py       264)     # update current position - and play start time if playing
sync_gui.py       265)     self.stPosition = value
sync_gui.py       266)     # update position state (do not touch the slider)
sync_gui.py       267)     self.updatePositionState()
Stefan Schuermans show current position as h:...

Stefan Schuermans authored 10 years ago

sync_gui.py       268) 
Stefan Schuermans initial PyGtk window

Stefan Schuermans authored 10 years ago

sync_gui.py       269)   def onPrevious(self, widget):
Stefan Schuermans start making player work -...

Stefan Schuermans authored 10 years ago

sync_gui.py       270)     """previous button as been pressed"""
Stefan Schuermans comments by ST

Stefan Schuermans authored 10 years ago

stage_director.py 271)     #print("DEBUG stage_director previous")
Stefan Schuermans remove forward and backward...

Stefan Schuermans authored 10 years ago

sync_gui.py       272)     # go to begin of previous entry (with wrap around)
sync_gui.py       273)     self.stPosition = 0
sync_gui.py       274)     self.stEntryIdx = self.stEntryIdx - 1
sync_gui.py       275)     if self.stEntryIdx < 0:
sync_gui.py       276)       self.stEntryIdx = len(self.playlist.entries) - 1
sync_gui.py       277)     self.updateEntry()
Stefan Schuermans initial PyGtk window

Stefan Schuermans authored 10 years ago

sync_gui.py       278) 
Stefan Schuermans comments by ST

Stefan Schuermans authored 10 years ago

stage_director.py 279)   def onPlay(self, widget):
stage_director.py 280)     """play button has been pressed"""
stage_director.py 281)     #print("DEBUG stage_director play")
stage_director.py 282)     self.stPlaying = True
Stefan Schuermans start making player work -...

Stefan Schuermans authored 10 years ago

sync_gui.py       283)     self.updatePosition()
sync_gui.py       284)     self.updateButtonVisibility()
Stefan Schuermans initial PyGtk window

Stefan Schuermans authored 10 years ago

sync_gui.py       285) 
sync_gui.py       286)   def onPause(self, widget):
Stefan Schuermans start making player work -...

Stefan Schuermans authored 10 years ago

sync_gui.py       287)     """pause button has been pressed"""
Stefan Schuermans comments by ST

Stefan Schuermans authored 10 years ago

stage_director.py 288)     #print("DEBUG stage_director pause")
Stefan Schuermans start making player work -...

Stefan Schuermans authored 10 years ago

sync_gui.py       289)     self.stPlaying = False
sync_gui.py       290)     self.updateButtonVisibility()
Stefan Schuermans initial PyGtk window

Stefan Schuermans authored 10 years ago

sync_gui.py       291) 
Stefan Schuermans comments by ST

Stefan Schuermans authored 10 years ago

stage_director.py 292)   def onStop(self, widget):
stage_director.py 293)     """stop button has been pressed"""
stage_director.py 294)     #print("DEBUG stage_director stop")
stage_director.py 295)     self.stPlaying = False
stage_director.py 296)     self.stPosition = 0 # stop goes back to begin
Stefan Schuermans start making player work -...

Stefan Schuermans authored 10 years ago

sync_gui.py       297)     self.updatePosition()
sync_gui.py       298)     self.updateButtonVisibility()
Stefan Schuermans initial PyGtk window

Stefan Schuermans authored 10 years ago

sync_gui.py       299) 
sync_gui.py       300)   def onNext(self, widget):
Stefan Schuermans start making player work -...

Stefan Schuermans authored 10 years ago

sync_gui.py       301)     """next button has been pressed"""
Stefan Schuermans comments by ST

Stefan Schuermans authored 10 years ago

stage_director.py 302)     #print("DEBUG stage_director next")
Stefan Schuermans remove forward and backward...

Stefan Schuermans authored 10 years ago

sync_gui.py       303)     # go to begin of next entry (with wrap around)
sync_gui.py       304)     self.stPosition = 0
sync_gui.py       305)     self.stEntryIdx = self.stEntryIdx + 1
sync_gui.py       306)     if self.stEntryIdx >= len(self.playlist.entries):
sync_gui.py       307)       self.stEntryIdx = 0
sync_gui.py       308)     self.updateEntry()
Stefan Schuermans start making player work -...

Stefan Schuermans authored 10 years ago

sync_gui.py       309) 
sync_gui.py       310)   def onTimer10ms(self):
sync_gui.py       311)     """timer callback, every 10ms"""
sync_gui.py       312)     # update position if playing
sync_gui.py       313)     if self.stPlaying:
sync_gui.py       314)       self.stPosition = time.time() - self.stPlayStart
Stefan Schuermans remove forward and backward...

Stefan Schuermans authored 10 years ago

sync_gui.py       315)       if self.stPosition >= self.stDuration:
sync_gui.py       316)         # end of entry reached --> go to begin of next entry (with wrap around)
sync_gui.py       317)         self.stPosition = 0
sync_gui.py       318)         self.stEntryIdx = self.stEntryIdx + 1
sync_gui.py       319)         if self.stEntryIdx >= len(self.playlist.entries):
sync_gui.py       320)           self.stEntryIdx = 0
sync_gui.py       321)         self.updateEntry()
sync_gui.py       322)       else:
sync_gui.py       323)         self.updatePosition()
Stefan Schuermans implement UDP output and de...

Stefan Schuermans authored 10 years ago

sync_gui.py       324)     # request being called again
sync_gui.py       325)     return True
Stefan Schuermans implement UDP sync protocol...

Stefan Schuermans authored 10 years ago

sync_gui.py       326) 
sync_gui.py       327)   def onTimer100ms(self):
sync_gui.py       328)     """timer callback, every 100ms"""
sync_gui.py       329)     # send sync packet
Stefan Schuermans implement UDP output and de...

Stefan Schuermans authored 10 years ago

sync_gui.py       330)     if self.sock is not None:
sync_gui.py       331)       flags = 0
sync_gui.py       332)       if self.stPlaying:
sync_gui.py       333)         flags = flags | 1
sync_gui.py       334)       name = self.stName
sync_gui.py       335)       pos_ms = round(self.stPosition * 1000)
sync_gui.py       336)       data = "PoSy" + struct.pack("!I64sI", flags, name, pos_ms)
sync_gui.py       337)       try:
sync_gui.py       338)         self.sock.send(data)
sync_gui.py       339)       except:
sync_gui.py       340)         self.closeSock()
sync_gui.py       341)     # request being called again
sync_gui.py       342)     return True
Stefan Schuermans start making player work -...

Stefan Schuermans authored 10 years ago

sync_gui.py       343) 
sync_gui.py       344) # main application entry point
Stefan Schuermans initial PyGtk window

Stefan Schuermans authored 10 years ago

sync_gui.py       345) if __name__ == "__main__":
sync_gui.py       346)   app = SyncGui()
sync_gui.py       347)   Gtk.main()
sync_gui.py       348)