media-tracks
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -19,30 +19,38 @@ import { VideoTrack } from "./video-track.js"; | ||
)?.get; | ||
Object.defineProperty(HTMLMediaElement.prototype, "videoTracks", { | ||
get() { | ||
return initVideoTrackList(this); | ||
} | ||
}); | ||
Object.defineProperty(HTMLMediaElement.prototype, "audioTracks", { | ||
get() { | ||
return initAudioTrackList(this); | ||
} | ||
}); | ||
HTMLMediaElement.prototype.addVideoTrack = function(kind, label = "", language = "") { | ||
const videoTrackList = initVideoTrackList(this); | ||
const track = new VideoTrack(); | ||
track.kind = kind; | ||
track.label = label; | ||
track.language = language; | ||
videoTrackList.add(track); | ||
return track; | ||
}; | ||
HTMLMediaElement.prototype.addAudioTrack = function(kind, label = "", language = "") { | ||
const audioTrackList = initAudioTrackList(this); | ||
const track = new AudioTrack(); | ||
track.kind = kind; | ||
track.label = label; | ||
track.language = language; | ||
audioTrackList.add(track); | ||
return track; | ||
}; | ||
if (!HTMLMediaElement.prototype.videoTracks) { | ||
Object.defineProperty(HTMLMediaElement.prototype, "videoTracks", { | ||
get() { | ||
return initVideoTrackList(this); | ||
} | ||
}); | ||
} | ||
if (!HTMLMediaElement.prototype.audioTracks) { | ||
Object.defineProperty(HTMLMediaElement.prototype, "audioTracks", { | ||
get() { | ||
return initAudioTrackList(this); | ||
} | ||
}); | ||
} | ||
if (!HTMLMediaElement.prototype.addVideoTrack) { | ||
HTMLMediaElement.prototype.addVideoTrack = function(kind, label = "", language = "") { | ||
const videoTrackList = initVideoTrackList(this); | ||
const track = new VideoTrack(); | ||
track.kind = kind; | ||
track.label = label; | ||
track.language = language; | ||
videoTrackList.add(track); | ||
return track; | ||
}; | ||
} | ||
if (!HTMLMediaElement.prototype.addAudioTrack) { | ||
HTMLMediaElement.prototype.addAudioTrack = function(kind, label = "", language = "") { | ||
const audioTrackList = initAudioTrackList(this); | ||
const track = new AudioTrack(); | ||
track.kind = kind; | ||
track.label = label; | ||
track.language = language; | ||
audioTrackList.add(track); | ||
return track; | ||
}; | ||
} | ||
function initVideoTrackList(media) { | ||
@@ -98,3 +106,3 @@ let tracks = videoTrackLists.get(media); | ||
} | ||
if (globalThis.VideoTrack) { | ||
if (globalThis.VideoTrack && !globalThis.VideoTrack.prototype.renditions) { | ||
Object.defineProperty(globalThis.VideoTrack.prototype, "renditions", { | ||
@@ -106,3 +114,3 @@ get() { | ||
} | ||
if (globalThis.AudioTrack) { | ||
if (globalThis.AudioTrack && !globalThis.AudioTrack.prototype.renditions) { | ||
Object.defineProperty(globalThis.AudioTrack.prototype, "renditions", { | ||
@@ -109,0 +117,0 @@ get() { |
{ | ||
"name": "media-tracks", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Polyfill audio and video tracks with renditions.", | ||
@@ -5,0 +5,0 @@ "type": "module", |
# Media Tracks | ||
[![Version](https://img.shields.io/npm/v/media-tracks?style=flat-square)](https://www.npmjs.com/package/media-tracks) | ||
[![Badge size](https://img.badgesize.io/https://cdn.jsdelivr.net/npm/media-tracks/+esm?compression=gzip&label=gzip&style=flat-square)](https://cdn.jsdelivr.net/npm/media-tracks/+esm) | ||
Polyfills the media elements (`<audio>` or `<video>`) adding audio and video tracks (as [specced](https://html.spec.whatwg.org/multipage/media.html#media-resources-with-multiple-media-tracks)) and with renditions as proposed in [media-ui-extensions](https://github.com/video-dev/media-ui-extensions). | ||
@@ -4,0 +8,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25267
722
100