예제 #1
0
def matchSelectedSource(itemName):
    if UnDefType.UNDEF == items[_SOURCE_ITEM_NAME] \
            or UnDefType.NULL == items[_SOURCE_ITEM_NAME]:
        return False

    selectedCasts = cast_manager.findCasts(items[_SOURCE_ITEM_NAME])
    matchedCast = next(
        ifilter(lambda item: item.getPrefix() in itemName, selectedCasts),
        None)
    return None != matchedCast
예제 #2
0
def updateStream(event):
    selectedCasts = cast_manager.findCasts(items[_SOURCE_ITEM_NAME])

    if items[_STREAM_ITEM_NAME] == StringType(
            selectedCasts[0].getStreamName()):
        # same stream as the other cast -> force play
        playMusic(event)
    else:  # update the stream item value which will trigger play
        events.sendCommand(_STREAM_ITEM_NAME, selectedCasts[0].getStreamName())

    volumeItemName = selectedCasts[0].getVolumeName()
    volumeState = items[volumeItemName]
    if UnDefType.UNDEF != volumeState and UnDefType.NULL != volumeState:
        events.sendCommand('VT_Master_ChromeCastVolume',
                           str(volumeState.intValue()))
예제 #3
0
def playMusic(event):
    selectedCasts = cast_manager.findCasts(items[_SOURCE_ITEM_NAME])

    streamName = None
    streamItemValue = items[_STREAM_ITEM_NAME]
    if UnDefType.UNDEF ==  streamItemValue \
        or UnDefType.NULL == streamItemValue \
        or StringType('') == streamItemValue:
        streamName = None
    else:
        streamName = streamItemValue.toString()

    if None != streamName:
        cast_manager.playStream(streamName, selectedCasts)
        events.sendCommand(_MASTER_PLAYER_ITEM_NAME, 'PLAY')
    else:
        events.sendCommand(_MASTER_PLAYER_ITEM_NAME, 'PAUSE')
예제 #4
0
def pauseMusic(event):
    selectedCasts = cast_manager.findCasts(items[_SOURCE_ITEM_NAME])
    cast_manager.pause(selectedCasts)
    log.info("[Cast] Paused selected stream.")
예제 #5
0
 def testFindCasts_firstItemPrefix_returnsOne(self):
     casts = cast_manager.getAllCasts()
     result = cast_manager.findCasts(casts[0].getPrefix())
     self.assertEqual(1, len(result))
     self.assertEqual(casts[0], result[0])
예제 #6
0
 def testFindCasts_undef_returnsAll(self):
     casts = cast_manager.getAllCasts()
     result = cast_manager.findCasts(scope.UnDefType.UNDEF)
     self.assertEqual(len(casts), len(result))
예제 #7
0
 def testFindCasts_allStringType_returnsAll(self):
     casts = cast_manager.getAllCasts()
     result = cast_manager.findCasts(scope.StringType("ALL"))
     self.assertEqual(len(casts), len(result))
예제 #8
0
 def testFindCasts_all_returnsAll(self):
     casts = cast_manager.getAllCasts()
     result = cast_manager.findCasts("ALL")
     self.assertEqual(len(casts), len(result))
예제 #9
0
 def testFindCasts_invalidPrefixStringType_returnsEmptyList(self):
     casts = cast_manager.findCasts(scope.StringType("an invalid prefix"))
     self.assertEqual(0, len(casts))