mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-19 15:26:36 +00:00
Bar media player fixes (#18402)
This commit is contained in:
parent
81053f2e07
commit
184ef7b7ff
@ -56,6 +56,7 @@ import {
|
|||||||
BrowserMediaPlayer,
|
BrowserMediaPlayer,
|
||||||
ERR_UNSUPPORTED_MEDIA,
|
ERR_UNSUPPORTED_MEDIA,
|
||||||
} from "./browser-media-player";
|
} from "./browser-media-player";
|
||||||
|
import { debounce } from "../../common/util/debounce";
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface HASSDomEvents {
|
interface HASSDomEvents {
|
||||||
@ -118,8 +119,14 @@ export class BarMediaPlayer extends SubscribeMixin(LitElement) {
|
|||||||
public showResolvingNewMediaPicked() {
|
public showResolvingNewMediaPicked() {
|
||||||
this._tearDownBrowserPlayer();
|
this._tearDownBrowserPlayer();
|
||||||
this._newMediaExpected = true;
|
this._newMediaExpected = true;
|
||||||
|
// Sometimes the state does not update when playing media, like with TTS, so we wait max 2 secs and then stop waiting
|
||||||
|
this._debouncedResetMediaExpected();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _debouncedResetMediaExpected = debounce(() => {
|
||||||
|
this._newMediaExpected = false;
|
||||||
|
}, 2000);
|
||||||
|
|
||||||
public hideResolvingNewMediaPicked() {
|
public hideResolvingNewMediaPicked() {
|
||||||
this._newMediaExpected = false;
|
this._newMediaExpected = false;
|
||||||
}
|
}
|
||||||
@ -154,7 +161,7 @@ export class BarMediaPlayer extends SubscribeMixin(LitElement) {
|
|||||||
protected render() {
|
protected render() {
|
||||||
if (this._newMediaExpected) {
|
if (this._newMediaExpected) {
|
||||||
return html`
|
return html`
|
||||||
<div class="controls-progress">
|
<div class="controls-progress buffering">
|
||||||
${until(
|
${until(
|
||||||
// Only show spinner after 500ms
|
// Only show spinner after 500ms
|
||||||
new Promise((resolve) => {
|
new Promise((resolve) => {
|
||||||
@ -240,9 +247,13 @@ export class BarMediaPlayer extends SubscribeMixin(LitElement) {
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="controls-progress">
|
<div
|
||||||
|
class="controls-progress ${stateObj.state === "buffering"
|
||||||
|
? "buffering"
|
||||||
|
: ""}"
|
||||||
|
>
|
||||||
${stateObj.state === "buffering"
|
${stateObj.state === "buffering"
|
||||||
? html` <ha-circular-progress active></ha-circular-progress> `
|
? html`<ha-circular-progress active></ha-circular-progress>`
|
||||||
: html`
|
: html`
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
${controls === undefined
|
${controls === undefined
|
||||||
@ -541,7 +552,8 @@ export class BarMediaPlayer extends SubscribeMixin(LitElement) {
|
|||||||
return css`
|
return css`
|
||||||
:host {
|
:host {
|
||||||
display: flex;
|
display: flex;
|
||||||
min-height: 100px;
|
height: 100px;
|
||||||
|
box-sizing: border-box;
|
||||||
background: var(
|
background: var(
|
||||||
--ha-card-background,
|
--ha-card-background,
|
||||||
var(--card-background-color, white)
|
var(--card-background-color, white)
|
||||||
@ -627,12 +639,11 @@ export class BarMediaPlayer extends SubscribeMixin(LitElement) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
img {
|
img {
|
||||||
max-height: 100px;
|
height: 100%;
|
||||||
max-width: 100px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.app img {
|
.app img {
|
||||||
max-height: 68px;
|
height: 68px;
|
||||||
margin: 16px 0 16px 16px;
|
margin: 16px 0 16px 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -641,8 +652,7 @@ export class BarMediaPlayer extends SubscribeMixin(LitElement) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
:host([narrow]) {
|
:host([narrow]) {
|
||||||
min-height: 56px;
|
height: 57px;
|
||||||
max-height: 56px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
:host([narrow]) .controls-progress {
|
:host([narrow]) .controls-progress {
|
||||||
@ -650,6 +660,10 @@ export class BarMediaPlayer extends SubscribeMixin(LitElement) {
|
|||||||
min-width: 48px;
|
min-width: 48px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:host([narrow]) .controls-progress.buffering {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
:host([narrow]) .media-info {
|
:host([narrow]) .media-info {
|
||||||
padding-left: 8px;
|
padding-left: 8px;
|
||||||
}
|
}
|
||||||
@ -672,16 +686,6 @@ export class BarMediaPlayer extends SubscribeMixin(LitElement) {
|
|||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
}
|
}
|
||||||
|
|
||||||
:host([narrow]) img {
|
|
||||||
max-height: 56px;
|
|
||||||
max-width: 56px;
|
|
||||||
}
|
|
||||||
|
|
||||||
:host([narrow]) .blank-image {
|
|
||||||
height: 56px;
|
|
||||||
width: 56px;
|
|
||||||
}
|
|
||||||
|
|
||||||
:host([narrow]) mwc-linear-progress {
|
:host([narrow]) mwc-linear-progress {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
@ -286,7 +286,7 @@ class PanelMediaBrowser extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
:host([narrow]) ha-media-player-browse {
|
:host([narrow]) ha-media-player-browse {
|
||||||
height: calc(100vh - (80px + var(--header-height)));
|
height: calc(100vh - (57px + var(--header-height)));
|
||||||
}
|
}
|
||||||
|
|
||||||
ha-bar-media-player {
|
ha-bar-media-player {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user