Enable manual seeking to any part of the video via #s=SECONDS.
parent
14d344a1a6
commit
57350953a5
|
@ -31,7 +31,8 @@
|
|||
"webpack-dev-server": "^3.1.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"dashjs": "^2.9.0"
|
||||
"dashjs": "^2.9.0",
|
||||
"query-string": "^6.1.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "webpack",
|
||||
|
|
18
src/index.js
18
src/index.js
|
@ -1,4 +1,6 @@
|
|||
import dashjs from 'dashjs';
|
||||
import queryString from 'query-string';
|
||||
|
||||
import style from './player.styl';
|
||||
|
||||
// Nonce used by Webpack for CSP
|
||||
|
@ -8,11 +10,19 @@ const __webpack_nonce__ = 'uGo4I9ydb2hP393boc/24Vu7diUk/Mf84w9khcZkynk=';
|
|||
window.addEventListener('load', () => {
|
||||
const playerContainer = document.createElement('video');
|
||||
playerContainer.classList.add(style.video);
|
||||
playerContainer.loop = true;
|
||||
|
||||
// calculate start time
|
||||
const date = new Date();
|
||||
const localTime = date.getTime() - (1000 * 60 * date.getTimezoneOffset());
|
||||
const secondsOfDay = (localTime % (1000 * 60 * 60 * 24)) / 1000;
|
||||
const parsedHash = queryString.parse(window.location.query || window.location.hash);
|
||||
let secondsOfDay;
|
||||
if (parsedHash.s !== undefined) {
|
||||
// use query-provided start time
|
||||
secondsOfDay = parseInt(parsedHash.s, 10);
|
||||
} else {
|
||||
// calculate start time
|
||||
const date = new Date();
|
||||
const localTime = date.getTime() - (1000 * 60 * date.getTimezoneOffset());
|
||||
secondsOfDay = (localTime % (1000 * 60 * 60 * 24)) / 1000;
|
||||
}
|
||||
|
||||
// initialize video
|
||||
const player = dashjs.MediaPlayer().create();
|
||||
|
|
11
yarn.lock
11
yarn.lock
|
@ -4221,6 +4221,13 @@ qs@6.5.1:
|
|||
version "6.5.1"
|
||||
resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.1.tgz#349cdf6eef89ec45c12d7d5eb3fc0c870343a6d8"
|
||||
|
||||
query-string@^6.1.0:
|
||||
version "6.1.0"
|
||||
resolved "https://registry.yarnpkg.com/query-string/-/query-string-6.1.0.tgz#01e7d69f6a0940dac67a937d6c6325647aa4532a"
|
||||
dependencies:
|
||||
decode-uri-component "^0.2.0"
|
||||
strict-uri-encode "^2.0.0"
|
||||
|
||||
querystring-es3@^0.2.0:
|
||||
version "0.2.1"
|
||||
resolved "https://registry.yarnpkg.com/querystring-es3/-/querystring-es3-0.2.1.tgz#9ec61f79049875707d69414596fd907a4d711e73"
|
||||
|
@ -4946,6 +4953,10 @@ stream-shift@^1.0.0:
|
|||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/stream-shift/-/stream-shift-1.0.0.tgz#d5c752825e5367e786f78e18e445ea223a155952"
|
||||
|
||||
strict-uri-encode@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz#b9c7330c7042862f6b142dc274bbcc5866ce3546"
|
||||
|
||||
string-width@^1.0.1:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3"
|
||||
|
|
Loading…
Reference in New Issue