diff --git a/README.md b/README.md index 230cfc17..a69394f8 100644 --- a/README.md +++ b/README.md @@ -87,8 +87,44 @@ lovelace: | `menu_mode` | `hidden-top` | The menu mode to show by default. See [menu modes](#menu-modes) below.| | `menu_buttons.{frigate, live, clips, snapshots, frigate_ui}` | `true` | Whether or not to show these builtin actions in the card menu. | | `controls.nextprev` | `thumbnails` | When viewing media, what kind of controls to show to move to the previous/next media item. Acceptable values: `thumbnails`, `chevrons`, `none` . | +| `dimensions.aspect_ratio_mode` | `dynamic` | The aspect ratio mode to use. Acceptable values: `dynamic`, `static`, `unconstrained`. See [aspect ratios](#aspect-ratios) below.| +| `dimensions.aspect_ratio` | `16:9` | The aspect ratio to use. Acceptable values: `:` or `/`. See [aspect ratios](#aspect-ratios) below.| -### Advanced + + +#### Aspect Ratio + +The card can show live cameras, stored events (clip or snapshot) and an event gallery (clips or snapshots). Of these [views](#views), the gallery views have no intrinsic aspect-ratio, whereas the other views have the aspect-ratio of the media. + +The card aspect ratio can be changed with the `dimensions.aspect_ratio_mode` and `dimensions.aspect_ratio` appearance options. + +If no aspect ratio is specified or available, but one is needed then `16:9` will be used by default. + +#### `dimensions.aspect_ratio_mode`: + +| Option | Description | +| ------------- | --------------------------------------------- | +| `dynamic` | The aspect-ratio of the card will match the aspect-ratio of the last loaded media. | +| `static` | A fixed aspect-ratio (as defined by `dimensions.aspect_ratio`) will be applied to all views. | +| `unconstrained` | No aspect ratio is enforced in any view, the card will expand with the content (may be especially useful for a panel-mode dashboard). | + +#### `dimensions.aspect_ratio`: + +* `16 / 9` or `16:9`: Default widescreen ratio. +* `4 / 3` or `4:3`: Default fullscreen ratio. +* `/` or `:`: Any arbitrary aspect-ratio. + +#### Example aspect ratio configuration + +Have the card aspect-ratio dynamically follow the last loaded media, but use `4:3` as the default when there is no such media: + +```yaml +dimensions: + aspect_ratio_mode: dynamic + aspect_ratio: '4:3' +``` + +### Advanced Options | Option | Default | Description | | ------------- | - | --------------------------------------------- | diff --git a/package.json b/package.json index 50ff7ff0..0313b1fa 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,6 @@ "@babel/plugin-proposal-class-properties": "^7.14.5", "@babel/plugin-proposal-decorators": "^7.15.4", "@rollup/plugin-json": "^4.1.0", - "@rollup/plugin-multi-entry": "^4.1.0", "@typescript-eslint/eslint-plugin": "^4.30.0", "@typescript-eslint/parser": "^4.30.0", "eslint": "^7.32.0", diff --git a/rollup.config.js b/rollup.config.js index 3b875029..30276be4 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -6,7 +6,6 @@ import { terser } from 'rollup-plugin-terser'; import serve from 'rollup-plugin-serve'; import json from '@rollup/plugin-json'; import styles from 'rollup-plugin-styles'; -import multi from '@rollup/plugin-multi-entry'; const dev = process.env.ROLLUP_WATCH; @@ -21,7 +20,6 @@ const serveopts = { }; const plugins = [ - multi(), styles({ modules: false, // Behavior of inject mode, without actually injecting style @@ -44,7 +42,7 @@ const plugins = [ export default [ { - input: ['src/card.ts'], + input: 'src/card.ts', output: { file: 'dist/frigate-hass-card.js', format: 'es', diff --git a/src/card.ts b/src/card.ts index a51e2ed5..5a16a5ad 100644 --- a/src/card.ts +++ b/src/card.ts @@ -9,6 +9,7 @@ import { } from 'lit'; import { customElement, property, query, state } from 'lit/decorators'; import { classMap } from 'lit/directives/class-map.js'; +import { styleMap } from 'lit/directives/style-map.js'; import { HomeAssistant, LovelaceCardEditor, @@ -17,14 +18,12 @@ import { stateIcon, } from 'custom-card-helpers'; -import { - MenuButton, - frigateCardConfigSchema, -} from './types'; +import { MenuButton, frigateCardConfigSchema } from './types'; import type { BrowseMediaQueryParameters, ExtendedHomeAssistant, FrigateCardConfig, + MediaLoadInfo, } from './types'; import { CARD_VERSION } from './const'; @@ -39,9 +38,31 @@ import './components/live'; import './components/menu'; import './components/message'; import './components/viewer'; +import './patches/ha-camera-stream'; +import './patches/ha-hls-player'; import cardStyle from './scss/card.scss'; +const MEDIA_HEIGHT_CUTOFF = 50; +const MEDIA_WIDTH_CUTOFF = MEDIA_HEIGHT_CUTOFF; + +/** A note on media callbacks: + * + * We need media elements (e.g.