Skip to content

Commit

Permalink
feat(target-live-window): Add basic support for m-ui-e targetLiveWind…
Browse files Browse the repository at this point in the history
…ow proposal.
  • Loading branch information
cjpillsbury committed Feb 15, 2023
1 parent aed1f9c commit 72e9705
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/js/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export const MediaUIAttributes = {
MEDIA_LOADING: 'media-loading',
MEDIA_BUFFERED: 'media-buffered',
MEDIA_STREAM_TYPE: 'media-stream-type',
MEDIA_TARGET_LIVE_WINDOW: 'media-target-live-window',
MEDIA_TIME_IS_LIVE: 'media-time-is-live',
};

Expand Down
14 changes: 13 additions & 1 deletion src/js/media-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,11 @@ class MediaController extends MediaContainer {
MediaUIAttributes.MEDIA_STREAM_TYPE
);
},
'emptied,durationchange,loadedmetadata,targetlivewindowchange': () => {
this.propagateMediaState(
MediaUIAttributes.MEDIA_TARGET_LIVE_WINDOW
);
},
'loadedmetadata,emptied,progress': () => {
this.propagateMediaState(
MediaUIAttributes.MEDIA_SEEKABLE,
Expand Down Expand Up @@ -1013,6 +1018,9 @@ const Delegates = {
[MediaUIAttributes.MEDIA_STREAM_TYPE](el) {
return getStreamType(el);
},
[MediaUIAttributes.MEDIA_TARGET_LIVE_WINDOW](el) {
return getTargetLiveWindow(el);
},
[MediaUIAttributes.MEDIA_TIME_IS_LIVE](controller) {
const media = controller.media;

Expand Down Expand Up @@ -1160,7 +1168,11 @@ const getStreamType = (controller) => {
}
}

return null;
return undefined;
};

const getTargetLiveWindow = (controller) => {
return controller?.media?.targetLiveWindow;
};

const MEDIA_UI_ATTRIBUTE_NAMES = Object.values(MediaUIAttributes);
Expand Down

0 comments on commit 72e9705

Please sign in to comment.