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

Stefan Schuermans authored 10 years ago

stage_director.py  70)     GObject.timeout_add(10, self.onTimer10ms)
stage_director.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 = ""
Stefan Schuermans allow names for STOP playli...

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

sync_gui.py       126)     # make current entry bold, all others non-bold
sync_gui.py       127)     def update(model, path, it, user_data):
sync_gui.py       128)       (idx,) = model.get(it, 0)
sync_gui.py       129)       if idx == self.stEntryIdx:
Stefan Schuermans fix pause flag in output, u...

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

sync_gui.py       133)       model.set(it, 1, weight)
sync_gui.py       134)     self.widPlaylistStore.foreach(update, None)
Stefan Schuermans remove forward and backward...

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

sync_gui.py       267) 
Stefan Schuermans initial PyGtk window

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

sync_gui.py       277) 
Stefan Schuermans comments by ST

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

sync_gui.py       290) 
Stefan Schuermans comments by ST

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

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

Stefan Schuermans authored 10 years ago

sync_gui.py       354)   Gtk.main()
sync_gui.py       355)