changeset 2423:4a5b37acd1f0

private attrs
author drewp@bigasterisk.com
date Thu, 23 May 2024 11:25:58 -0700
parents 62dc1b3644a0
children 4b8f8fabeb2f
files src/light9/ascoltami/player.py
diffstat 1 files changed, 19 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/src/light9/ascoltami/player.py	Tue May 21 16:11:28 2024 -0700
+++ b/src/light9/ascoltami/player.py	Thu May 23 11:25:58 2024 -0700
@@ -23,11 +23,11 @@
         self.autoStopOffset = autoStopOffset
         self.playbin = self.pipeline = Gst.ElementFactory.make('playbin', None)
 
-        self.playStartTime = 0
-        self.lastWatchTime = 0
-        self.autoStopTime = 0
-        self.lastSetSongUri = None
-        self.onEOS = onEOS
+        self._playStartTime = 0
+        self._lastWatchTime = 0
+        self._autoStopTime = 0
+        self._lastSetSongUri = None
+        self._onEOS = onEOS
 
         task.LoopingCall(self.watchTime).start(.050)
 
@@ -40,13 +40,13 @@
             self.pollForMessages()
 
             t = self.currentTime()
-            log.debug("watch %s < %s < %s", self.lastWatchTime,
-                      self.autoStopTime, t)
-            if self.lastWatchTime < self.autoStopTime < t:
+            log.debug("watch %s < %s < %s", self._lastWatchTime,
+                      self._autoStopTime, t)
+            if self._lastWatchTime < self._autoStopTime < t:
                 log.info("autostop")
                 self.pause()
 
-            self.lastWatchTime = t
+            self._lastWatchTime = t
         except Exception:
             traceback.print_exc()
 
@@ -57,8 +57,8 @@
 
         def onEos(*args):
             print("onEos", args)
-            if self.onEOS is not None:
-                self.onEOS(self.getSong())
+            if self._onEOS is not None:
+                self._onEOS(self.getSong())
 
         bus.connect('message::eos', onEos)
 
@@ -86,8 +86,8 @@
             if msg.type == mt.ERROR:
                 log.error(repr(msg.parse_error()))
             if msg.type == mt.EOS:
-                if self.onEOS is not None:
-                    self.onEOS(self.getSong())
+                if self._onEOS is not None:
+                    self._onEOS(self.getSong())
             if msg.type == mt.STREAM_STATUS:
                 (statusType, _elem) = msg.parse_stream_status()
                 if statusType == Gst.StreamStatusType.ENTER:
@@ -100,7 +100,7 @@
             t * Gst.SECOND)
         if not isSeekable:
             raise ValueError('seek_simple failed')
-        self.playStartTime = time.time()
+        self._playStartTime = time.time()
 
     def setSong(self, songLoc, play=True):
         """
@@ -110,16 +110,16 @@
         self.pipeline.set_state(Gst.State.READY)
         self.preload(songLoc)
         self.pipeline.set_property("uri", songLoc)
-        self.lastSetSongUri = songLoc
+        self._lastSetSongUri = songLoc
         # todo: don't have any error report yet if the uri can't be read
         if play:
             self.pipeline.set_state(Gst.State.PLAYING)
-            self.playStartTime = time.time()
+            self._playStartTime = time.time()
 
     def getSong(self):
         """Returns the URI of the current song."""
         # even the 'uri' that I just set isn't readable yet
-        return self.playbin.get_property("uri") or self.lastSetSongUri
+        return self.playbin.get_property("uri") or self._lastSetSongUri
 
     def preload(self, songPath):
         """
@@ -184,8 +184,8 @@
         dur = self.duration()
         if dur == 0:
             raise ValueError("duration=0, can't set autostop")
-        self.autoStopTime = (dur - self.autoStopOffset)
-        log.info("autostop will be at %s", self.autoStopTime)
+        self._autoStopTime = (dur - self.autoStopOffset)
+        log.info("autostop will be at %s", self._autoStopTime)
         # pipeline.seek can take a stop time, but using that wasn't
         # working out well. I'd get pauses at other times that were
         # hard to remove.