014a03d1af76a5eb22648661e1b65dc8afed2104
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 support synchronizing video...

Stefan Schuermans authored 10 years ago

stage_director.py   4) # Copyright 2013-2014 Stefan Schuermans <stefan@schuermans.info>
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 fix warning about Gtk version

Stefan Schuermans authored 6 years ago

stage_director.py   8) import gi
stage_director.py   9) gi.require_version('Gtk', '3.0')
stage_director.py  10) 
Stefan Schuermans initial PyGtk window

Stefan Schuermans authored 10 years ago

sync_gui.py        11) import os
Stefan Schuermans allow names for STOP playli...

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

stage_director.py  14) from gi.repository import Pango
Stefan Schuermans implement UDP sync protocol...

Stefan Schuermans authored 10 years ago

sync_gui.py        15) import socket
sync_gui.py        16) import struct
Stefan Schuermans add menu, implement file open

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

sync_gui.py        18) import time
Stefan Schuermans reading playlist

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

sync_gui.py        20) import time_fmt
sync_gui.py        21) 
Stefan Schuermans initial PyGtk window

Stefan Schuermans authored 10 years ago

sync_gui.py        22) scriptdir = os.path.dirname(os.path.abspath(__file__))
sync_gui.py        23) 
Stefan Schuermans rename SyncGui class to Sta...

Stefan Schuermans authored 10 years ago

stage_director.py  24) class StageDirector:
Stefan Schuermans start making player work -...

Stefan Schuermans authored 10 years ago

sync_gui.py        25) 
Stefan Schuermans initial PyGtk window

Stefan Schuermans authored 10 years ago

sync_gui.py        26)   def __init__(self):
Stefan Schuermans rename SyncGui class to Sta...

Stefan Schuermans authored 10 years ago

stage_director.py  27)     """construct a StageDirector object"""
Stefan Schuermans initial PyGtk window

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

stage_director.py  29)     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        30)     self.widMainWindow = self.builder.get_object("MainWindow")
Stefan Schuermans start making player work -...

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

sync_gui.py        39)     self.widLogoStop = self.builder.get_object("LogoStop")
sync_gui.py        40)     self.widLogoPlay = self.builder.get_object("LogoPlay")
sync_gui.py        41)     self.widLogoUdpErr = self.builder.get_object("LogoUdpErr")
sync_gui.py        42)     self.widLogoUdpOk = self.builder.get_object("LogoUdpOk")
Stefan Schuermans add single-step mode

Stefan Schuermans authored 10 years ago

stage_director.py  43)     self.widSingleStep = self.builder.get_object("SingleStep")
Stefan Schuermans allow turning off UDP output

Stefan Schuermans authored 10 years ago

stage_director.py  44)     self.widUdpOutput = self.builder.get_object("UdpOutput")
Stefan Schuermans implement UDP output and de...

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

sync_gui.py        47)       "onDestroy":           self.onDestroy,
sync_gui.py        48)       "onFileOpen":          self.onFileOpen,
sync_gui.py        49)       "onFileExit":          self.onFileExit,
sync_gui.py        50)       "onExtrasDestination": self.onExtrasDestination,
Stefan Schuermans comments by ST

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

sync_gui.py        52)       "onPlaylistDblClick":  self.onPlaylistDblClick,
sync_gui.py        53)       "onNewPosition":       self.onNewPosition,
sync_gui.py        54)       "onPrevious":          self.onPrevious,
sync_gui.py        55)       "onPlay":              self.onPlay,
Stefan Schuermans comments by ST

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

sync_gui.py        58)       "onNext":              self.onNext,
Stefan Schuermans allow turning off UDP output

Stefan Schuermans authored 10 years ago

stage_director.py  59)       "onUdpOutput":         self.onUdpOutput,
Stefan Schuermans initial PyGtk window

Stefan Schuermans authored 10 years ago

sync_gui.py        60)     }
sync_gui.py        61)     self.builder.connect_signals(handlers)
Stefan Schuermans reading playlist

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

sync_gui.py        67)     self.stEntryIdx = -1 # no entry selected
sync_gui.py        68)     self.stName = "" # no current entry name
sync_gui.py        69)     self.stDuration = 0 # current entry has zero size
sync_gui.py        70)     self.stPosition = 0 # at begin of current entry
sync_gui.py        71)     self.stPlaying = False # not playing
Stefan Schuermans implement UDP output and de...

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

sync_gui.py       121)     # clear selection of playlist
sync_gui.py       122)     sel = self.widPlaylistView.get_selection()
sync_gui.py       123)     if sel:
sync_gui.py       124)       sel.unselect_all()
Stefan Schuermans show current playlist item...

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

sync_gui.py       131)       self.stName = self.playlist.entries[self.stEntryIdx]["name"]
Stefan Schuermans show current playlist item...

Stefan Schuermans authored 10 years ago

sync_gui.py       132)     # make current entry bold, all others non-bold
Stefan Schuermans scroll newly selected entry...

Stefan Schuermans authored 10 years ago

stage_director.py 133)     # scroll current entry into view
stage_director.py 134)     def update(model, path, it, stageDirector):
Stefan Schuermans show current playlist item...

Stefan Schuermans authored 10 years ago

sync_gui.py       135)       (idx,) = model.get(it, 0)
sync_gui.py       136)       if idx == self.stEntryIdx:
Stefan Schuermans fix pause flag in output, u...

Stefan Schuermans authored 10 years ago

stage_director.py 137)         weight = Pango.Weight.BOLD
Stefan Schuermans scroll newly selected entry...

Stefan Schuermans authored 10 years ago

stage_director.py 138)         stageDirector.widPlaylistView.scroll_to_cell(path)
Stefan Schuermans show current playlist item...

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

sync_gui.py       141)       model.set(it, 1, weight)
Stefan Schuermans scroll newly selected entry...

Stefan Schuermans authored 10 years ago

stage_director.py 142)     self.widPlaylistStore.foreach(update, self)
Stefan Schuermans add single-step mode

Stefan Schuermans authored 10 years ago

stage_director.py 143)     # 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       144)     # -> stop playing and update button visibility
Stefan Schuermans add single-step mode

Stefan Schuermans authored 10 years ago

stage_director.py 145)     if self.stPlaying and \
stage_director.py 146)        (self.stEntryIdx < 0 or \
stage_director.py 147)         self.playlist.entries[self.stEntryIdx]["type"] == "stop" or \
stage_director.py 148)         self.widSingleStep.get_active()):
Stefan Schuermans remove forward and backward...

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

sync_gui.py       151)     # update duration, position, ...
sync_gui.py       152)     self.updateDuration()
sync_gui.py       153) 
Stefan Schuermans start making player work -...

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

sync_gui.py       165)     self.widStatus.remove_all(0)
Stefan Schuermans allow turning off UDP output

Stefan Schuermans authored 10 years ago

stage_director.py 166)     self.widStatus.push(0, "UDP output turned off")
Stefan Schuermans implement UDP output and de...

Stefan Schuermans authored 10 years ago

sync_gui.py       167)     if self.sock is not None:
sync_gui.py       168)       self.sock.close()
sync_gui.py       169)     self.sock = None
sync_gui.py       170) 
sync_gui.py       171)   def setupSock(self):
sync_gui.py       172)     """create a new UDP socket and "connect" it to the destination address"""
sync_gui.py       173)     self.closeSock()
Stefan Schuermans allow turning off UDP output

Stefan Schuermans authored 10 years ago

stage_director.py 174)     if self.widUdpOutput.get_active():
stage_director.py 175)       try:
stage_director.py 176)         self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
stage_director.py 177)         self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
stage_director.py 178)         self.sock.connect((self.stDestination, 5740))
stage_director.py 179)         self.widStatus.remove_all(0)
stage_director.py 180)         self.widStatus.push(0, "UDP output to \"" + self.stDestination +
stage_director.py 181)                                "\" port 5740")
stage_director.py 182)         self.widLogoUdpErr.set_visible(False)
stage_director.py 183)         self.widLogoUdpOk.set_visible(True)
stage_director.py 184)       except:
stage_director.py 185)         self.closeSock()
stage_director.py 186)         self.widStatus.push(0, "UDP output ERROR")
Stefan Schuermans implement UDP output and de...

Stefan Schuermans authored 10 years ago

sync_gui.py       187) 
Stefan Schuermans initial PyGtk window

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

sync_gui.py       190)     Gtk.main_quit()
sync_gui.py       191) 
Stefan Schuermans add menu, implement file open

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

sync_gui.py       198)       self.widMainWindow, Gtk.FileChooserAction.OPEN,
sync_gui.py       199)       (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
sync_gui.py       200)        Gtk.STOCK_OPEN, Gtk.ResponseType.OK))
Stefan Schuermans add menu, implement file open

Stefan Schuermans authored 10 years ago

sync_gui.py       201)     dialog.set_default_response(Gtk.ResponseType.OK)
sync_gui.py       202)     filt = Gtk.FileFilter()
sync_gui.py       203)     filt.set_name("All files")
sync_gui.py       204)     filt.add_pattern("*")
sync_gui.py       205)     dialog.add_filter(filt)
sync_gui.py       206)     response = dialog.run()
sync_gui.py       207)     if response == Gtk.ResponseType.OK:
sync_gui.py       208)       # dialog closed with OK -> load new playlist
sync_gui.py       209)       filename = dialog.get_filename()
sync_gui.py       210)       self.playlist.read(filename)
sync_gui.py       211)       self.playlist.update(self.widPlaylistStore)
sync_gui.py       212)       self.stEntryIdx = -1 # no entry selected
sync_gui.py       213)       self.stPlaying = False # not playing
sync_gui.py       214)       self.updateEntry()
sync_gui.py       215)       self.updateButtonVisibility()
Stefan Schuermans implement UDP output and de...

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

sync_gui.py       217)     dialog.destroy()
sync_gui.py       218) 
sync_gui.py       219)   def onFileExit(self, widget):
sync_gui.py       220)     """File Exit clicked in menu"""
Stefan Schuermans comments by ST

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

sync_gui.py       222)     Gtk.main_quit()
sync_gui.py       223) 
Stefan Schuermans implement UDP output and de...

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

sync_gui.py       227)     # run input dialog to ask for new destination
sync_gui.py       228)     dialog = self.builder.get_object("DialogDestination")
sync_gui.py       229)     cur = self.builder.get_object("DiaDestCur")
sync_gui.py       230)     new = self.builder.get_object("DiaDestNew")
sync_gui.py       231)     cur.set_text(self.stDestination)
sync_gui.py       232)     new.set_text(self.stDestination)
sync_gui.py       233)     response = dialog.run()
sync_gui.py       234)     if response == 1:
sync_gui.py       235)       self.stDestination = new.get_text()
sync_gui.py       236)     # hide input dialog
sync_gui.py       237)     dialog.hide()
sync_gui.py       238)     # re-create UDP socket
sync_gui.py       239)     self.setupSock()
sync_gui.py       240) 
Stefan Schuermans comments by ST

Stefan Schuermans authored 10 years ago

stage_director.py 241)   def onExtrasAbout(self, widget):
stage_director.py 242)     """Extras About clicked in menu"""
stage_director.py 243)     #print("DEBUG stage_director Extras About")
stage_director.py 244)     # run about dialog
stage_director.py 245)     dialog = self.builder.get_object("DialogAbout")
stage_director.py 246)     dialog.run()
stage_director.py 247)     dialog.hide()
stage_director.py 248) 
Stefan Schuermans start making player work -...

Stefan Schuermans authored 10 years ago

sync_gui.py       249)   def onPlaylistDblClick(self, widget, row, col):
sync_gui.py       250)     """playlist entry has been double-clicked"""
sync_gui.py       251)     # get index of selected entry
sync_gui.py       252)     idx = -1
sync_gui.py       253)     sel = self.widPlaylistView.get_selection()
sync_gui.py       254)     if sel is not None:
sync_gui.py       255)       (model, it) = sel.get_selected()
sync_gui.py       256)       if it is not None:
Stefan Schuermans show current playlist item...

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

sync_gui.py       261)     # set position to zero if playing
sync_gui.py       262)     if self.stPlaying:
sync_gui.py       263)       self.stPosition = 0
Stefan Schuermans show current playlist item...

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

sync_gui.py       270)     # clamp position to valid range
sync_gui.py       271)     if value < 0:
sync_gui.py       272)       value = 0
sync_gui.py       273)     if value > self.stDuration:
sync_gui.py       274)       value = self.stDuration
sync_gui.py       275)     # update current position - and play start time if playing
sync_gui.py       276)     self.stPosition = value
sync_gui.py       277)     # update position state (do not touch the slider)
sync_gui.py       278)     self.updatePositionState()
Stefan Schuermans show current position as h:...

Stefan Schuermans authored 10 years ago

sync_gui.py       279) 
Stefan Schuermans initial PyGtk window

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

sync_gui.py       283)     # go to begin of previous entry (with wrap around)
sync_gui.py       284)     self.stPosition = 0
sync_gui.py       285)     self.stEntryIdx = self.stEntryIdx - 1
sync_gui.py       286)     if self.stEntryIdx < 0:
sync_gui.py       287)       self.stEntryIdx = len(self.playlist.entries) - 1
sync_gui.py       288)     self.updateEntry()
Stefan Schuermans initial PyGtk window

Stefan Schuermans authored 10 years ago

sync_gui.py       289) 
Stefan Schuermans comments by ST

Stefan Schuermans authored 10 years ago

stage_director.py 290)   def onPlay(self, widget):
stage_director.py 291)     """play button has been pressed"""
stage_director.py 292)     #print("DEBUG stage_director play")
stage_director.py 293)     self.stPlaying = True
Stefan Schuermans start making player work -...

Stefan Schuermans authored 10 years ago

sync_gui.py       294)     self.updatePosition()
sync_gui.py       295)     self.updateButtonVisibility()
Stefan Schuermans initial PyGtk window

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

sync_gui.py       300)     self.stPlaying = False
sync_gui.py       301)     self.updateButtonVisibility()
Stefan Schuermans initial PyGtk window

Stefan Schuermans authored 10 years ago

sync_gui.py       302) 
Stefan Schuermans comments by ST

Stefan Schuermans authored 10 years ago

stage_director.py 303)   def onStop(self, widget):
stage_director.py 304)     """stop button has been pressed"""
stage_director.py 305)     #print("DEBUG stage_director stop")
stage_director.py 306)     self.stPlaying = False
stage_director.py 307)     self.stPosition = 0 # stop goes back to begin
Stefan Schuermans start making player work -...

Stefan Schuermans authored 10 years ago

sync_gui.py       308)     self.updatePosition()
sync_gui.py       309)     self.updateButtonVisibility()
Stefan Schuermans initial PyGtk window

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

sync_gui.py       314)     # go to begin of next entry (with wrap around)
sync_gui.py       315)     self.stPosition = 0
sync_gui.py       316)     self.stEntryIdx = self.stEntryIdx + 1
sync_gui.py       317)     if self.stEntryIdx >= len(self.playlist.entries):
sync_gui.py       318)       self.stEntryIdx = 0
sync_gui.py       319)     self.updateEntry()
Stefan Schuermans start making player work -...

Stefan Schuermans authored 10 years ago

sync_gui.py       320) 
Stefan Schuermans allow turning off UDP output

Stefan Schuermans authored 10 years ago

stage_director.py 321)   def onUdpOutput(self, widget):
stage_director.py 322)     """UDP Output check box toggled"""
stage_director.py 323)     # re-create UDP socket
stage_director.py 324)     self.setupSock()
stage_director.py 325) 
Stefan Schuermans start making player work -...

Stefan Schuermans authored 10 years ago

sync_gui.py       326)   def onTimer10ms(self):
sync_gui.py       327)     """timer callback, every 10ms"""
sync_gui.py       328)     # update position if playing
sync_gui.py       329)     if self.stPlaying:
sync_gui.py       330)       self.stPosition = time.time() - self.stPlayStart
Stefan Schuermans remove forward and backward...

Stefan Schuermans authored 10 years ago

sync_gui.py       331)       if self.stPosition >= self.stDuration:
sync_gui.py       332)         # end of entry reached --> go to begin of next entry (with wrap around)
sync_gui.py       333)         self.stPosition = 0
sync_gui.py       334)         self.stEntryIdx = self.stEntryIdx + 1
sync_gui.py       335)         if self.stEntryIdx >= len(self.playlist.entries):
sync_gui.py       336)           self.stEntryIdx = 0
sync_gui.py       337)         self.updateEntry()
sync_gui.py       338)       else:
sync_gui.py       339)         self.updatePosition()
Stefan Schuermans implement UDP output and de...

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

sync_gui.py       342) 
sync_gui.py       343)   def onTimer100ms(self):
sync_gui.py       344)     """timer callback, every 100ms"""
sync_gui.py       345)     # send sync packet
Stefan Schuermans implement UDP output and de...

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

sync_gui.py       349)         flags = flags | 1
sync_gui.py       350)       name = self.stName
sync_gui.py       351)       pos_ms = round(self.stPosition * 1000)
sync_gui.py       352)       data = "PoSy" + struct.pack("!I64sI", flags, name, pos_ms)
sync_gui.py       353)       try:
sync_gui.py       354)         self.sock.send(data)
sync_gui.py       355)       except:
sync_gui.py       356)         self.closeSock()
sync_gui.py       357)     # request being called again
sync_gui.py       358)     return True
Stefan Schuermans start making player work -...

Stefan Schuermans authored 10 years ago

sync_gui.py       359) 
sync_gui.py       360) # main application entry point
Stefan Schuermans initial PyGtk window

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

stage_director.py 363)   try:
stage_director.py 364)     settings = Gtk.Settings.get_default()
stage_director.py 365)     settings.props.gtk_button_images = True
stage_director.py 366)   except:
stage_director.py 367)     pass
Stefan Schuermans force icons on GTK stock bu...

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

sync_gui.py       371)   Gtk.main()
sync_gui.py       372)