Add a code comment on the pains of media callbacks.

This commit is contained in:
Dermot Duffy
2021-09-24 07:45:58 -07:00
parent 32cc7d1a70
commit fee4d209c9
+17
View File
@@ -46,6 +46,23 @@ import cardStyle from './scss/card.scss';
const MEDIA_HEIGHT_CUTOFF = 50; const MEDIA_HEIGHT_CUTOFF = 50;
const MEDIA_WIDTH_CUTOFF = MEDIA_HEIGHT_CUTOFF; const MEDIA_WIDTH_CUTOFF = MEDIA_HEIGHT_CUTOFF;
/** A note on media callbacks:
*
* We need media elements (e.g. <video>, <img> or <canvas>) to callback when:
* - Metadata is loaded / dimensions are known (for aspect-ratio)
* - Media is playing / paused (to avoid reloading)
*
* There are a number of different approaches used to attach event handlers to
* get these callbacks (which need to be attached directly to the media
* elements, which may be 'buried' down the DOM):
* - Extend the `ha-hls-player` and `ha-camera-stream` to specify the required
* hooks (as querySelecting the media elements after rendering was a fight
* with the Lit rendering engine and was very fragile) .
* - For non-Lit elements (e.g. WebRTC) query selecting after rendering.
* - Library provided hooks (e.g. JSMPEG)
* - Directly specifying hooks (e.g. for snapshot viewing with simple <img> tags)
*/
/* eslint no-console: 0 */ /* eslint no-console: 0 */
console.info( console.info(
`%c FRIGATE-HASS-CARD \n%c ${localize('common.version')} ${CARD_VERSION} `, `%c FRIGATE-HASS-CARD \n%c ${localize('common.version')} ${CARD_VERSION} `,