本文整理汇总了Python中pylgtv.WebOsClient.channel_up方法的典型用法代码示例。如果您正苦于以下问题:Python WebOsClient.channel_up方法的具体用法?Python WebOsClient.channel_up怎么用?Python WebOsClient.channel_up使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pylgtv.WebOsClient
的用法示例。
在下文中一共展示了WebOsClient.channel_up方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: LgWebOSDevice
# 需要导入模块: from pylgtv import WebOsClient [as 别名]
# 或者: from pylgtv.WebOsClient import channel_up [as 别名]
#.........这里部分代码省略.........
def volume_up(self):
"""Volume up the media player."""
self._client.volume_up()
def volume_down(self):
"""Volume down media player."""
self._client.volume_down()
def set_volume_level(self, volume):
"""Set volume level, range 0..1."""
tv_volume = volume * 100
self._client.set_volume(tv_volume)
def mute_volume(self, mute):
"""Send mute command."""
self._muted = mute
self._client.set_mute(mute)
def media_play_pause(self):
"""Simulate play pause media player."""
if self._playing:
self.media_pause()
else:
self.media_play()
def select_source(self, source):
"""Select input source."""
source_dict = self._source_list.get(source)
if source_dict is None:
_LOGGER.warning("Source %s not found for %s", source, self.name)
return
self._current_source_id = source_dict['id']
if source_dict.get('title'):
self._current_source = source_dict['title']
self._client.launch_app(source_dict['id'])
elif source_dict.get('label'):
self._current_source = source_dict['label']
self._client.set_input(source_dict['id'])
def play_media(self, media_type, media_id, **kwargs):
"""Play a piece of media."""
_LOGGER.debug(
"Call play media type <%s>, Id <%s>", media_type, media_id)
if media_type == MEDIA_TYPE_CHANNEL:
_LOGGER.debug("Searching channel...")
partial_match_channel_id = None
perfect_match_channel_id = None
for channel in self._client.get_channels():
if media_id == channel['channelNumber']:
perfect_match_channel_id = channel['channelId']
continue
elif media_id.lower() == channel['channelName'].lower():
perfect_match_channel_id = channel['channelId']
continue
elif media_id.lower() in channel['channelName'].lower():
partial_match_channel_id = channel['channelId']
if perfect_match_channel_id is not None:
_LOGGER.info(
"Switching to channel <%s> with perfect match",
perfect_match_channel_id)
self._client.set_channel(perfect_match_channel_id)
elif partial_match_channel_id is not None:
_LOGGER.info(
"Switching to channel <%s> with partial match",
partial_match_channel_id)
self._client.set_channel(partial_match_channel_id)
return
def media_play(self):
"""Send play command."""
self._playing = True
self._state = STATE_PLAYING
self._client.play()
def media_pause(self):
"""Send media pause command to media player."""
self._playing = False
self._state = STATE_PAUSED
self._client.pause()
def media_next_track(self):
"""Send next track command."""
current_input = self._client.get_input()
if current_input == LIVETV_APP_ID:
self._client.channel_up()
else:
self._client.fast_forward()
def media_previous_track(self):
"""Send the previous track command."""
current_input = self._client.get_input()
if current_input == LIVETV_APP_ID:
self._client.channel_down()
else:
self._client.rewind()