commit/StationPlaylist: josephsl: Encoder Hive (6.0-dev): Foundation for saving settings across sessions.

  • From: commits-noreply@xxxxxxxxxxxxx
  • To: nvda-addons-commits@xxxxxxxxxxxxx
  • Date: Wed, 05 Aug 2015 02:02:21 -0000

1 new commit in StationPlaylist:

https://bitbucket.org/nvdaaddonteam/stationplaylist/commits/7a02e39e2abe/
Changeset: 7a02e39e2abe
Branch: 6.0/encoderHive
User: josephsl
Date: 2015-08-05 02:01:55+00:00
Summary: Encoder Hive (6.0-dev): Foundation for saving settings across
sessions.

Stream labels file will be updated to support saving settings such as focus to
Studio across sessions.
Also, couple helpers added, including a dedicated function to retrieve encoder
identifier and a flag setter to configure options, previously scattered around
encoder classes.
This will be available in 6.0.

Affected #: 1 file

diff --git a/addon/globalPlugins/SPLStudioUtils/encoders.py
b/addon/globalPlugins/SPLStudioUtils/encoders.py
index 273dc46..be2addd 100755
--- a/addon/globalPlugins/SPLStudioUtils/encoders.py
+++ b/addon/globalPlugins/SPLStudioUtils/encoders.py
@@ -47,7 +47,7 @@ streamLabels = None

# Load stream labels (and possibly other future goodies) from a file-based
database.
def loadStreamLabels():
- global streamLabels, SAMStreamLabels, SPLStreamLabels
+ global streamLabels, SAMStreamLabels, SPLStreamLabels, SPLFocusToStudio
streamLabels = ConfigObj(os.path.join(globalVars.appArgs.configPath,
"splStreamLabels.ini"))
# Read stream labels.
try:
@@ -58,6 +58,10 @@ def loadStreamLabels():
SPLStreamLabels = dict(streamLabels["SPLEncoders"])
except KeyError:
SPLStreamLabels = {}
+ # Read other settings.
+ if "FocusToStudio" in streamLabels:
+ SPLFocusToStudio = set(streamLabels["FocusToStudio"])
+

# Report number of encoders being monitored.
# 6.0: Refactor the below function to use the newer encoder config format.
@@ -118,6 +122,13 @@ class Encoder(IAccessible):
playAfterConnecting = False # When connected, the first track will be
played.
backgroundMonitor = False # Monitor this encoder for connection status
changes.

+ # Some helper functions
+
+ # Get the encoder identifier.
+ # This consists of two or three letter abbreviations for the encoder
and the child ID.
+ def getEncoderId(self):
+ return " ".join([self.encoderType,
str(self.IAccessibleChildID)])
+
# Format the status message to prepare for monitoring multiple encoders.
def encoderStatusMessage(self, message, id):
if encoderMonCount[self.encoderType] > 1:
@@ -126,6 +137,20 @@ class Encoder(IAccessible):
else:
ui.message(message)

+ # A master flag setter.
+ # Set or clear a given flag for the encoder given its ID, flag and flag
container (currently a feature set).
+ # Also take in the flag key for storing it into the settings file.
+ # The flag will then be written to the configuration file.
+ def _set_Flags(self, encoderId, flag, flagMap, flagKey):
+ if flag and not encoderId in flagMap:
+ flagMap.add(encoderId)
+ elif not flag and encoderId in flagMap:
+ flagMap.remove(encoderId)
+ streamLabels[flagKey] = list(flagMap)
+
+ # Now the flag configuration scripts.
+ # Project Rainbow: a new way to configure these will be created.
+
def script_toggleFocusToStudio(self, gesture):
if not self.focusToStudio:
self.focusToStudio = True
@@ -232,7 +257,7 @@ class Encoder(IAccessible):
def initOverlayClass(self):
# Load stream labels upon request.
if not streamLabels: loadStreamLabels()
- encoderIdentifier = " ".join([self.encoderType,
str(self.IAccessibleChildID)])
+ encoderIdentifier = self.getEncoderId()
# Can I switch to Studio when connected to a streaming server?
try:
self.focusToStudio = encoderIdentifier in
SPLFocusToStudio
@@ -352,14 +377,20 @@ class SAMEncoder(Encoder):
# Translators: Presented when SAM Encoder is disconnecting from
a streaming server.
ui.message(_("Disconnecting..."))

+ # The following mutators will be removed as part of Project Rainbow.
+ # These will be kept in 6.0 for backwards compatibility.
+
def _set_FocusToStudio(self):
+ #self._set_Flags(self.getEncoderId(), self.focusToStudio,
SPLFocusToStudio, "FocusToStudio")
SAMIdentifier = " ".join([self.encoderType,
str(self.IAccessibleChildID)])
if self.focusToStudio and not SAMIdentifier in SPLFocusToStudio:
SPLFocusToStudio.add(SAMIdentifier)
elif not self.focusToStudio and SAMIdentifier in
SPLFocusToStudio:
SPLFocusToStudio.remove(SAMIdentifier)
+ streamLabels["FocusToStudio"] = list(SPLFocusToStudio)

def setPlayAfterConnecting(self):
+ #self._set_Flags(self.getEncoderId(), self.playAfterConnecting,
SPLPlayAfterConnecting, "PlayAfterConnecting")
SAMIdentifier = " ".join([self.encoderType,
str(self.IAccessibleChildID)])
if self.playAfterConnecting and not SAMIdentifier in
SPLPlayAfterConnecting:
SPLPlayAfterConnecting.add(SAMIdentifier)
@@ -367,6 +398,7 @@ class SAMEncoder(Encoder):
SPLPlayAfterConnecting.remove(SAMIdentifier)

def setBackgroundMonitor(self):
+ #self._set_Flags(self.getEncoderId(), self.backgroundMonitor,
SPLBackgroundMonitor, "BackgroundMonitor")
SAMIdentifier = " ".join([self.encoderType,
str(self.IAccessibleChildID)])
if self.backgroundMonitor and not SAMIdentifier in
SPLBackgroundMonitor:
SPLBackgroundMonitor.add(SAMIdentifier)

Repository URL: https://bitbucket.org/nvdaaddonteam/stationplaylist/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.

Other related posts:

  • » commit/StationPlaylist: josephsl: Encoder Hive (6.0-dev): Foundation for saving settings across sessions. - commits-noreply