|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
import { hydrating } from '../../hydration.js';
|
|
|
|
|
import { render_effect, effect } from '../../../reactivity/effects.js';
|
|
|
|
|
import { listen } from './shared.js';
|
|
|
|
|
import { yield_updates } from '../../../runtime.js';
|
|
|
|
|
|
|
|
|
|
/** @param {TimeRanges} ranges */
|
|
|
|
|
function time_ranges_to_array(ranges) {
|
|
|
|
@ -35,7 +36,7 @@ export function bind_current_time(media, get_value, update) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updating = true;
|
|
|
|
|
update(media.currentTime);
|
|
|
|
|
yield_updates(() => update(media.currentTime));
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
raf_id = requestAnimationFrame(callback);
|
|
|
|
@ -60,7 +61,9 @@ export function bind_current_time(media, get_value, update) {
|
|
|
|
|
* @param {(array: Array<{ start: number; end: number }>) => void} update
|
|
|
|
|
*/
|
|
|
|
|
export function bind_buffered(media, update) {
|
|
|
|
|
listen(media, ['loadedmetadata', 'progress'], () => update(time_ranges_to_array(media.buffered)));
|
|
|
|
|
listen(media, ['loadedmetadata', 'progress'], () =>
|
|
|
|
|
yield_updates(() => update(time_ranges_to_array(media.buffered)))
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -76,7 +79,9 @@ export function bind_seekable(media, update) {
|
|
|
|
|
* @param {(array: Array<{ start: number; end: number }>) => void} update
|
|
|
|
|
*/
|
|
|
|
|
export function bind_played(media, update) {
|
|
|
|
|
listen(media, ['timeupdate'], () => update(time_ranges_to_array(media.played)));
|
|
|
|
|
listen(media, ['timeupdate'], () =>
|
|
|
|
|
yield_updates(() => update(time_ranges_to_array(media.played)))
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -84,7 +89,7 @@ export function bind_played(media, update) {
|
|
|
|
|
* @param {(seeking: boolean) => void} update
|
|
|
|
|
*/
|
|
|
|
|
export function bind_seeking(media, update) {
|
|
|
|
|
listen(media, ['seeking', 'seeked'], () => update(media.seeking));
|
|
|
|
|
listen(media, ['seeking', 'seeked'], () => yield_updates(() => update(media.seeking)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -92,7 +97,7 @@ export function bind_seeking(media, update) {
|
|
|
|
|
* @param {(seeking: boolean) => void} update
|
|
|
|
|
*/
|
|
|
|
|
export function bind_ended(media, update) {
|
|
|
|
|
listen(media, ['timeupdate', 'ended'], () => update(media.ended));
|
|
|
|
|
listen(media, ['timeupdate', 'ended'], () => yield_updates(() => update(media.ended)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -103,7 +108,7 @@ export function bind_ready_state(media, update) {
|
|
|
|
|
listen(
|
|
|
|
|
media,
|
|
|
|
|
['loadedmetadata', 'loadeddata', 'canplay', 'canplaythrough', 'playing', 'waiting', 'emptied'],
|
|
|
|
|
() => update(media.readyState)
|
|
|
|
|
() => yield_updates(() => update(media.readyState))
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -127,7 +132,7 @@ export function bind_playback_rate(media, get_value, update) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
listen(media, ['ratechange'], () => {
|
|
|
|
|
if (!updating) update(media.playbackRate);
|
|
|
|
|
if (!updating) yield_updates(() => update(media.playbackRate));
|
|
|
|
|
updating = false;
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
@ -145,7 +150,7 @@ export function bind_paused(media, get_value, update) {
|
|
|
|
|
var callback = () => {
|
|
|
|
|
if (paused !== media.paused) {
|
|
|
|
|
paused = media.paused;
|
|
|
|
|
update((paused = media.paused));
|
|
|
|
|
yield_updates(() => update((paused = media.paused)));
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -170,7 +175,7 @@ export function bind_paused(media, get_value, update) {
|
|
|
|
|
media.pause();
|
|
|
|
|
} else {
|
|
|
|
|
media.play().catch(() => {
|
|
|
|
|
update((paused = true));
|
|
|
|
|
yield_updates(() => update((paused = true)));
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
@ -234,7 +239,7 @@ export function bind_muted(media, get_value, update) {
|
|
|
|
|
|
|
|
|
|
var callback = () => {
|
|
|
|
|
updating = true;
|
|
|
|
|
update(media.muted);
|
|
|
|
|
yield_updates(() => update(media.muted));
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (get_value() == null) {
|
|
|
|
|