abb2b314f03ed1248149cb9b48fb1d5836dd2679
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 allow names for STOP playli...

Stefan Schuermans authored 10 years ago

stage_director.py   4) # Copyright 2013-2014 Stefan Schuermans <stefan@blinkenarea.org>
Stefan Schuermans add copyright, remove statu...

Stefan Schuermans authored 10 years ago

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
Stefan Schuermans allow names for STOP playli...

Stefan Schuermans authored 10 years ago

stage_director.py   9) from gi.repository import GObject
Stefan Schuermans initial PyGtk window

Stefan Schuermans authored 10 years ago

sync_gui.py        10) from gi.repository import Gtk
Stefan Schuermans use Pango from GTK3/gobj, d...

Stefan Schuermans authored 10 years ago

stage_director.py  11) from gi.repository 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) 
Stefan Schuermans rename SyncGui class to Sta...

Stefan Schuermans authored 10 years ago

stage_director.py  21) class StageDirector:
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 rename SyncGui class to Sta...

Stefan Schuermans authored 10 years ago

stage_director.py  24)     """construct a StageDirector 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 add single-step mode

Stefan Schuermans authored 10 years ago

stage_director.py  40)     self.widSingleStep = self.builder.get_object("SingleStep")
Stefan Schuermans implement UDP output and de...

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

sync_gui.py        70)     self.updateButtonVisibility()
Stefan Schuermans allow names for STOP playli...

Stefan Schuermans authored 10 years ago

stage_director.py  71)     GObject.timeout_add(10, self.onTimer10ms)
stage_director.py  72)     GObject.timeout_add(100, self.onTimer100ms)
Stefan Schuermans show current position as h:...

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

sync_gui.py       123)     # get name of current entry
sync_gui.py       124)     self.stName = ""
Stefan Schuermans allow names for STOP playli...

Stefan Schuermans authored 10 years ago

stage_director.py 125)     if self.stEntryIdx >= 0:
Stefan Schuermans add menu, implement file open

Stefan Schuermans authored 10 years ago

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:
Stefan Schuermans fix pause flag in output, u...

Stefan Schuermans authored 10 years ago

stage_director.py 131)         weight = Pango.Weight.BOLD
Stefan Schuermans show current playlist item...

Stefan Schuermans authored 10 years ago

sync_gui.py       132)       else:
Stefan Schuermans fix pause flag in output, u...

Stefan Schuermans authored 10 years ago

stage_director.py 133)         weight = Pango.Weight.NORMAL
Stefan Schuermans show current playlist item...

Stefan Schuermans authored 10 years ago

sync_gui.py       134)       model.set(it, 1, weight)
sync_gui.py       135)     self.widPlaylistStore.foreach(update, None)
Stefan Schuermans add single-step mode

Stefan Schuermans authored 10 years ago

stage_director.py 136)     # playing and (no entry or stop entry or single-step mode)
Stefan Schuermans remove forward and backward...

Stefan Schuermans authored 10 years ago

sync_gui.py       137)     # -> stop playing and update button visibility
Stefan Schuermans add single-step mode

Stefan Schuermans authored 10 years ago

stage_director.py 138)     if self.stPlaying and \
stage_director.py 139)        (self.stEntryIdx < 0 or \
stage_director.py 140)         self.playlist.entries[self.stEntryIdx]["type"] == "stop" or \
stage_director.py 141)         self.widSingleStep.get_active()):
Stefan Schuermans remove forward and backward...

Stefan Schuermans authored 10 years ago

sync_gui.py       142)       self.stPlaying = False
sync_gui.py       143)       self.updateButtonVisibility()
Stefan Schuermans show current playlist item...

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

sync_gui.py       176)     except:
sync_gui.py       177)       self.closeSock()
sync_gui.py       178) 
Stefan Schuermans initial PyGtk window

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

sync_gui.py       181)     Gtk.main_quit()
sync_gui.py       182) 
Stefan Schuermans add menu, implement file open

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

sync_gui.py       213)     Gtk.main_quit()
sync_gui.py       214) 
Stefan Schuermans implement UDP output and de...

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

stage_director.py 249)     #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       250)     # update playlist entry
sync_gui.py       251)     self.stEntryIdx = idx
Stefan Schuermans remove forward and backward...

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

sync_gui.py       270) 
Stefan Schuermans initial PyGtk window

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

sync_gui.py       280) 
Stefan Schuermans comments by ST

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

sync_gui.py       285)     self.updatePosition()
sync_gui.py       286)     self.updateButtonVisibility()
Stefan Schuermans initial PyGtk window

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

sync_gui.py       291)     self.stPlaying = False
sync_gui.py       292)     self.updateButtonVisibility()
Stefan Schuermans initial PyGtk window

Stefan Schuermans authored 10 years ago

sync_gui.py       293) 
Stefan Schuermans comments by ST

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

sync_gui.py       299)     self.updatePosition()
sync_gui.py       300)     self.updateButtonVisibility()
Stefan Schuermans initial PyGtk window

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

sync_gui.py       332)     if self.sock is not None:
sync_gui.py       333)       flags = 0
Stefan Schuermans fix pause flag in output, u...

Stefan Schuermans authored 10 years ago

stage_director.py 334)       if not self.stPlaying:
Stefan Schuermans implement UDP output and de...

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

sync_gui.py       345) 
sync_gui.py       346) # main application entry point
Stefan Schuermans initial PyGtk window

Stefan Schuermans authored 10 years ago

sync_gui.py       347) if __name__ == "__main__":
Stefan Schuermans force icons on GTK stock bu...

Stefan Schuermans authored 10 years ago

stage_director.py 348)   # configure settings
Stefan Schuermans use Pango from GTK3/gobj, d...

Stefan Schuermans authored 10 years ago

stage_director.py 349)   try:
stage_director.py 350)     settings = Gtk.Settings.get_default()
stage_director.py 351)     settings.props.gtk_button_images = True
stage_director.py 352)   except:
stage_director.py 353)     pass
Stefan Schuermans force icons on GTK stock bu...

Stefan Schuermans authored 10 years ago

stage_director.py 354)   # create window
Stefan Schuermans rename SyncGui class to Sta...

Stefan Schuermans authored 10 years ago

stage_director.py 355)   app = StageDirector()
Stefan Schuermans force icons on GTK stock bu...

Stefan Schuermans authored 10 years ago

stage_director.py 356)   # run application
Stefan Schuermans initial PyGtk window

Stefan Schuermans authored 10 years ago

sync_gui.py       357)   Gtk.main()
sync_gui.py       358)