mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Media Player and cast improvements
This commit is contained in:
parent
678be46bb9
commit
afd99a0c6c
@ -1,2 +1,2 @@
|
||||
""" DO NOT MODIFY. Auto-generated by build_frontend script """
|
||||
VERSION = "d9e860658bd8d9767b748b1b193776e6"
|
||||
VERSION = "6fb0e76d325bb7472fa25355e60539cd"
|
||||
|
@ -22208,13 +22208,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
<div class="horizontal justified layout">
|
||||
<state-info state-obj="[[stateObj]]"></state-info>
|
||||
<div class="state">
|
||||
<template is="dom-if" if="[[stateObj.attributes.media_title]]">
|
||||
<div class="main-text">[[stateObj.attributes.media_title]]</div>
|
||||
<div class="secondary-text">[[stateObj.stateDisplay]]</div>
|
||||
</template>
|
||||
<template is="dom-if" if="[[!stateObj.attributes.media_title]]">
|
||||
<div class="main-text">[[stateObj.stateDisplay]]</div>
|
||||
</template>
|
||||
<div class="main-text">[[computePrimaryText(stateObj)]]</div>
|
||||
<div class="secondary-text">[[computeSecondaryText(stateObj)]]</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@ -22230,6 +22225,14 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
type: Object,
|
||||
},
|
||||
},
|
||||
|
||||
computePrimaryText: function(stateObj) {
|
||||
return stateObj.attributes.media_title || stateObj.stateDisplay;
|
||||
},
|
||||
|
||||
computeSecondaryText: function(stateObj) {
|
||||
return stateObj.attributes.media_title ? stateObj.stateDisplay : '';
|
||||
},
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
@ -25726,9 +25729,9 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
<template>
|
||||
<div class="layout horizontal">
|
||||
<div class="flex">
|
||||
<paper-button on-tap="handleTogglePower">[[computePowerButtonCaption(isIdle)]]</paper-button>
|
||||
<paper-icon-button icon="power-settings-new" on-tap="handleTogglePower"></paper-icon-button>
|
||||
</div>
|
||||
<div class="">
|
||||
<div>
|
||||
<template is="dom-if" if="[[!isIdle]]">
|
||||
<paper-icon-button icon="av:skip-previous" on-tap="handlePrevious"></paper-icon-button>
|
||||
<paper-icon-button icon="[[computePlayPauseIcon(stateObj)]]" on-tap="handlePlayPause"></paper-icon-button>
|
||||
|
@ -32,13 +32,8 @@
|
||||
<div class='horizontal justified layout'>
|
||||
<state-info state-obj="[[stateObj]]"></state-info>
|
||||
<div class='state'>
|
||||
<template is='dom-if' if='[[stateObj.attributes.media_title]]'>
|
||||
<div class='main-text'>[[stateObj.attributes.media_title]]</div>
|
||||
<div class='secondary-text'>[[stateObj.stateDisplay]]</div>
|
||||
</template>
|
||||
<template is='dom-if' if='[[!stateObj.attributes.media_title]]'>
|
||||
<div class='main-text'>[[stateObj.stateDisplay]]</div>
|
||||
</template>
|
||||
<div class='main-text'>[[computePrimaryText(stateObj)]]</div>
|
||||
<div class='secondary-text'>[[computeSecondaryText(stateObj)]]</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@ -54,6 +49,14 @@
|
||||
type: Object,
|
||||
},
|
||||
},
|
||||
|
||||
computePrimaryText: function(stateObj) {
|
||||
return stateObj.attributes.media_title || stateObj.stateDisplay;
|
||||
},
|
||||
|
||||
computeSecondaryText: function(stateObj) {
|
||||
return stateObj.attributes.media_title ? stateObj.stateDisplay : '';
|
||||
},
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
|
@ -1,6 +1,5 @@
|
||||
<link rel='import' href='../bower_components/polymer/polymer.html'>
|
||||
|
||||
<link rel='import' href='../bower_components/paper-button/paper-button.html'>
|
||||
<link rel='import' href='../bower_components/paper-icon-button/paper-icon-button.html'>
|
||||
|
||||
<dom-module id='more-info-media_player'>
|
||||
@ -16,9 +15,10 @@
|
||||
<template>
|
||||
<div class='layout horizontal'>
|
||||
<div class='flex'>
|
||||
<paper-button on-tap='handleTogglePower'>[[computePowerButtonCaption(isIdle)]]</paper-button>
|
||||
<paper-icon-button icon='power-settings-new'
|
||||
on-tap='handleTogglePower'></paper-icon-button>
|
||||
</div>
|
||||
<div class=''>
|
||||
<div>
|
||||
<template is='dom-if' if='[[!isIdle]]'>
|
||||
<paper-icon-button icon='av:skip-previous'
|
||||
on-tap='handlePrevious'></paper-icon-button>
|
||||
|
@ -130,6 +130,7 @@ SERVICE_TO_METHOD = {
|
||||
SERVICE_MEDIA_PLAY: 'media_play',
|
||||
SERVICE_MEDIA_PAUSE: 'media_pause',
|
||||
SERVICE_MEDIA_NEXT_TRACK: 'media_next_track',
|
||||
SERVICE_MEDIA_PREV_TRACK: 'media_prev_track',
|
||||
}
|
||||
|
||||
|
||||
@ -211,6 +212,10 @@ class MediaPlayerDevice(Entity):
|
||||
""" media_pause media player. """
|
||||
pass
|
||||
|
||||
def media_prev_track(self):
|
||||
""" media_prev_track media player. """
|
||||
pass
|
||||
|
||||
def media_next_track(self):
|
||||
""" media_next_track media player. """
|
||||
pass
|
||||
|
@ -24,6 +24,8 @@ from homeassistant.components.media_player import (
|
||||
MEDIA_STATE_PLAYING, MEDIA_STATE_PAUSED, MEDIA_STATE_STOPPED,
|
||||
MEDIA_STATE_UNKNOWN)
|
||||
|
||||
CAST_SPLASH = 'https://home-assistant.io/images/cast/splash.png'
|
||||
|
||||
|
||||
# pylint: disable=unused-argument
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
@ -130,6 +132,13 @@ class CastDevice(MediaPlayerDevice):
|
||||
|
||||
return state_attr
|
||||
|
||||
def turn_on(self):
|
||||
""" Turns on the ChromeCast. """
|
||||
# The only way we can turn the Chromecast is on is by launching an app
|
||||
if not self.cast.status.is_active_input:
|
||||
self.cast.play_media(
|
||||
CAST_SPLASH, pychromecast.STREAM_TYPE_BUFFERED)
|
||||
|
||||
def turn_off(self):
|
||||
""" Service to exit any running app on the specimedia player ChromeCast and
|
||||
shows idle screen. Will quit all ChromeCasts if nothing specified.
|
||||
@ -163,6 +172,14 @@ class CastDevice(MediaPlayerDevice):
|
||||
if self.media_state == MEDIA_STATE_PLAYING:
|
||||
self.cast.media_controller.pause()
|
||||
|
||||
def media_prev_track(self):
|
||||
""" media_prev_track media player. """
|
||||
self.cast.media_controller.rewind()
|
||||
|
||||
def media_next_track(self):
|
||||
""" media_next_track media player. """
|
||||
self.cast.media_controller.skip()
|
||||
|
||||
def play_youtube_video(self, video_id):
|
||||
""" Plays specified video_id on the Chromecast's YouTube channel. """
|
||||
self.youtube.play_video(video_id)
|
||||
@ -170,7 +187,6 @@ class CastDevice(MediaPlayerDevice):
|
||||
def new_cast_status(self, status):
|
||||
""" Called when a new cast status is received. """
|
||||
self.cast_status = status
|
||||
self.media_status = None
|
||||
self.update_ha_state()
|
||||
|
||||
def new_media_status(self, status):
|
||||
|
@ -18,7 +18,7 @@ phue>=0.8
|
||||
ledcontroller>=1.0.7
|
||||
|
||||
# media_player.cast
|
||||
pychromecast>=0.6.0.3
|
||||
pychromecast>=0.6.2
|
||||
|
||||
# keyboard
|
||||
pyuserinput>=0.1.9
|
||||
|
Loading…
x
Reference in New Issue
Block a user