timingsrc 1.2.6 → 1.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/es2019/factories/compute-velocity.d.ts +2 -0
- package/build/es2019/factories/compute-velocity.d.ts.map +1 -0
- package/build/es2019/factories/compute-velocity.js +2 -0
- package/build/es2019/factories/compute-velocity.js.map +1 -0
- package/build/es2019/factories/default-set-timingsrc.d.ts +9 -2
- package/build/es2019/factories/default-set-timingsrc.d.ts.map +1 -1
- package/build/es2019/factories/default-set-timingsrc.js +6 -3
- package/build/es2019/factories/default-set-timingsrc.js.map +1 -1
- package/build/es2019/factories/set-current-time.d.ts +1 -2
- package/build/es2019/factories/set-current-time.d.ts.map +1 -1
- package/build/es2019/factories/set-current-time.js.map +1 -1
- package/build/es2019/factories/set-playback-rate.d.ts +1 -2
- package/build/es2019/factories/set-playback-rate.d.ts.map +1 -1
- package/build/es2019/factories/set-playback-rate.js.map +1 -1
- package/build/es2019/factories/set-timingsrc-with-custom-update-function.d.ts +6 -2
- package/build/es2019/factories/set-timingsrc-with-custom-update-function.d.ts.map +1 -1
- package/build/es2019/factories/set-timingsrc-with-custom-update-function.js +30 -10
- package/build/es2019/factories/set-timingsrc-with-custom-update-function.js.map +1 -1
- package/build/es2019/factories/set-timingsrc.d.ts +5 -2
- package/build/es2019/factories/set-timingsrc.d.ts.map +1 -1
- package/build/es2019/factories/set-timingsrc.js +1 -3
- package/build/es2019/factories/set-timingsrc.js.map +1 -1
- package/build/es2019/factories/update-gradually.d.ts +7 -2
- package/build/es2019/factories/update-gradually.d.ts.map +1 -1
- package/build/es2019/factories/update-gradually.js +18 -7
- package/build/es2019/factories/update-gradually.js.map +1 -1
- package/build/es2019/factories/update-media-element.d.ts +5 -2
- package/build/es2019/factories/update-media-element.d.ts.map +1 -1
- package/build/es2019/factories/update-media-element.js.map +1 -1
- package/build/es2019/factories/update-stepwise-factory.d.ts +12 -2
- package/build/es2019/factories/update-stepwise-factory.d.ts.map +1 -1
- package/build/es2019/factories/update-stepwise-factory.js +98 -25
- package/build/es2019/factories/update-stepwise-factory.js.map +1 -1
- package/build/es2019/factories/window.d.ts +1 -2
- package/build/es2019/factories/window.d.ts.map +1 -1
- package/build/es2019/factories/window.js.map +1 -1
- package/build/es2019/functions/determine-supported-playback-rate-values.d.ts +2 -1
- package/build/es2019/functions/determine-supported-playback-rate-values.d.ts.map +1 -1
- package/build/es2019/functions/determine-supported-playback-rate-values.js.map +1 -1
- package/build/es2019/functions/update-vector-with-new-position.d.ts +6 -0
- package/build/es2019/functions/update-vector-with-new-position.d.ts.map +1 -0
- package/build/es2019/functions/update-vector-with-new-position.js +5 -0
- package/build/es2019/functions/update-vector-with-new-position.js.map +1 -0
- package/build/es2019/module.d.ts +11 -3
- package/build/es2019/module.d.ts.map +1 -1
- package/build/es2019/module.js +3 -1
- package/build/es2019/module.js.map +1 -1
- package/build/es2019/types/index.d.ts +1 -17
- package/build/es2019/types/index.d.ts.map +1 -1
- package/build/es2019/types/index.js +1 -17
- package/build/es2019/types/index.js.map +1 -1
- package/build/es2019/types/update-function.d.ts +1 -1
- package/build/es2019/types/update-function.d.ts.map +1 -1
- package/build/es2019/types/update-vector-with-custom-state.d.ts +3 -0
- package/build/es2019/types/update-vector-with-custom-state.d.ts.map +1 -0
- package/build/es2019/types/update-vector-with-custom-state.js +2 -0
- package/build/es2019/types/update-vector-with-custom-state.js.map +1 -0
- package/build/es5/bundle.js +202 -72
- package/package.json +8 -8
- package/src/factories/compute-velocity.ts +2 -0
- package/src/factories/default-set-timingsrc.ts +30 -19
- package/src/factories/set-current-time.ts +2 -4
- package/src/factories/set-playback-rate.ts +2 -4
- package/src/factories/set-timingsrc-with-custom-update-function.ts +59 -16
- package/src/factories/set-timingsrc.ts +14 -4
- package/src/factories/update-gradually.ts +37 -8
- package/src/factories/update-media-element.ts +18 -3
- package/src/factories/update-stepwise-factory.ts +133 -38
- package/src/factories/window.ts +1 -3
- package/src/functions/determine-supported-playback-rate-values.ts +3 -1
- package/src/functions/update-vector-with-new-position.ts +9 -0
- package/src/module.ts +4 -0
- package/src/types/index.ts +1 -17
- package/src/types/update-function.ts +5 -1
- package/src/types/update-vector-with-custom-state.ts +5 -0
- package/build/es2019/types/default-timingsrc-factory.d.ts +0 -8
- package/build/es2019/types/default-timingsrc-factory.d.ts.map +0 -1
- package/build/es2019/types/default-timingsrc-factory.js +0 -2
- package/build/es2019/types/default-timingsrc-factory.js.map +0 -1
- package/build/es2019/types/determine-supported-playback-rate-values-function.d.ts +0 -2
- package/build/es2019/types/determine-supported-playback-rate-values-function.d.ts.map +0 -1
- package/build/es2019/types/determine-supported-playback-rate-values-function.js +0 -2
- package/build/es2019/types/determine-supported-playback-rate-values-function.js.map +0 -1
- package/build/es2019/types/pause-function.d.ts +0 -2
- package/build/es2019/types/pause-function.d.ts.map +0 -1
- package/build/es2019/types/pause-function.js +0 -2
- package/build/es2019/types/pause-function.js.map +0 -1
- package/build/es2019/types/play-function.d.ts +0 -2
- package/build/es2019/types/play-function.d.ts.map +0 -1
- package/build/es2019/types/play-function.js +0 -2
- package/build/es2019/types/play-function.js.map +0 -1
- package/build/es2019/types/set-current-time-factory.d.ts +0 -3
- package/build/es2019/types/set-current-time-factory.d.ts.map +0 -1
- package/build/es2019/types/set-current-time-factory.js +0 -2
- package/build/es2019/types/set-current-time-factory.js.map +0 -1
- package/build/es2019/types/set-current-time-function.d.ts +0 -2
- package/build/es2019/types/set-current-time-function.d.ts.map +0 -1
- package/build/es2019/types/set-current-time-function.js +0 -2
- package/build/es2019/types/set-current-time-function.js.map +0 -1
- package/build/es2019/types/set-playback-rate-factory.d.ts +0 -3
- package/build/es2019/types/set-playback-rate-factory.d.ts.map +0 -1
- package/build/es2019/types/set-playback-rate-factory.js +0 -2
- package/build/es2019/types/set-playback-rate-factory.js.map +0 -1
- package/build/es2019/types/set-playback-rate-function.d.ts +0 -2
- package/build/es2019/types/set-playback-rate-function.d.ts.map +0 -1
- package/build/es2019/types/set-playback-rate-function.js +0 -2
- package/build/es2019/types/set-playback-rate-function.js.map +0 -1
- package/build/es2019/types/set-timingsrc-factory.d.ts +0 -5
- package/build/es2019/types/set-timingsrc-factory.d.ts.map +0 -1
- package/build/es2019/types/set-timingsrc-factory.js +0 -2
- package/build/es2019/types/set-timingsrc-factory.js.map +0 -1
- package/build/es2019/types/set-timingsrc-function.d.ts +0 -4
- package/build/es2019/types/set-timingsrc-function.d.ts.map +0 -1
- package/build/es2019/types/set-timingsrc-function.js +0 -2
- package/build/es2019/types/set-timingsrc-function.js.map +0 -1
- package/build/es2019/types/set-timingsrc-with-custom-update-function-factory.d.ts +0 -5
- package/build/es2019/types/set-timingsrc-with-custom-update-function-factory.d.ts.map +0 -1
- package/build/es2019/types/set-timingsrc-with-custom-update-function-factory.js +0 -2
- package/build/es2019/types/set-timingsrc-with-custom-update-function-factory.js.map +0 -1
- package/build/es2019/types/set-timingsrc-with-custom-update-function-function.d.ts +0 -5
- package/build/es2019/types/set-timingsrc-with-custom-update-function-function.d.ts.map +0 -1
- package/build/es2019/types/set-timingsrc-with-custom-update-function-function.js +0 -2
- package/build/es2019/types/set-timingsrc-with-custom-update-function-function.js.map +0 -1
- package/build/es2019/types/update-gradually-factory.d.ts +0 -4
- package/build/es2019/types/update-gradually-factory.d.ts.map +0 -1
- package/build/es2019/types/update-gradually-factory.js +0 -2
- package/build/es2019/types/update-gradually-factory.js.map +0 -1
- package/build/es2019/types/update-media-element-factory.d.ts +0 -7
- package/build/es2019/types/update-media-element-factory.d.ts.map +0 -1
- package/build/es2019/types/update-media-element-factory.js +0 -2
- package/build/es2019/types/update-media-element-factory.js.map +0 -1
- package/build/es2019/types/update-media-element-function.d.ts +0 -2
- package/build/es2019/types/update-media-element-function.d.ts.map +0 -1
- package/build/es2019/types/update-media-element-function.js +0 -2
- package/build/es2019/types/update-media-element-function.js.map +0 -1
- package/build/es2019/types/update-stepwise-factory-factory.d.ts +0 -4
- package/build/es2019/types/update-stepwise-factory-factory.d.ts.map +0 -1
- package/build/es2019/types/update-stepwise-factory-factory.js +0 -2
- package/build/es2019/types/update-stepwise-factory-factory.js.map +0 -1
- package/build/es2019/types/update-stepwise-factory.d.ts +0 -3
- package/build/es2019/types/update-stepwise-factory.d.ts.map +0 -1
- package/build/es2019/types/update-stepwise-factory.js +0 -2
- package/build/es2019/types/update-stepwise-factory.js.map +0 -1
- package/build/es2019/types/window-factory.d.ts +0 -2
- package/build/es2019/types/window-factory.d.ts.map +0 -1
- package/build/es2019/types/window-factory.js +0 -2
- package/build/es2019/types/window-factory.js.map +0 -1
- package/src/types/default-timingsrc-factory.ts +0 -15
- package/src/types/determine-supported-playback-rate-values-function.ts +0 -1
- package/src/types/pause-function.ts +0 -1
- package/src/types/play-function.ts +0 -1
- package/src/types/set-current-time-factory.ts +0 -3
- package/src/types/set-current-time-function.ts +0 -1
- package/src/types/set-playback-rate-factory.ts +0 -3
- package/src/types/set-playback-rate-function.ts +0 -1
- package/src/types/set-timingsrc-factory.ts +0 -8
- package/src/types/set-timingsrc-function.ts +0 -8
- package/src/types/set-timingsrc-with-custom-update-function-factory.ts +0 -10
- package/src/types/set-timingsrc-with-custom-update-function-function.ts +0 -10
- package/src/types/update-gradually-factory.ts +0 -9
- package/src/types/update-media-element-factory.ts +0 -12
- package/src/types/update-media-element-function.ts +0 -8
- package/src/types/update-stepwise-factory-factory.ts +0 -4
- package/src/types/update-stepwise-factory.ts +0 -3
- package/src/types/window-factory.ts +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../src/module.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../src/module.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AASrE,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAE9B,OAAO,EAAE,qBAAqB,EAAE,CAAC;AAEjC,eAAO,MAAM,oBAAoB;;;;;;;;EAA0D,CAAC;AAI5F,eAAO,MAAM,oCAAoC,sVAKhD,CAAC;AAEF,eAAO,MAAM,YAAY,4LASxB,CAAC"}
|
package/build/es2019/module.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { animationFrame, on } from 'subscribable-things';
|
|
2
2
|
import { translateTimingStateVector } from 'timing-object';
|
|
3
|
+
import { createComputeVelocity } from './factories/compute-velocity';
|
|
3
4
|
import { createDefaultSetTimingsrc } from './factories/default-set-timingsrc';
|
|
4
5
|
import { createSetCurrentTime } from './factories/set-current-time';
|
|
5
6
|
import { createSetPlaybackRate } from './factories/set-playback-rate';
|
|
@@ -12,10 +13,11 @@ import { createWindow } from './factories/window';
|
|
|
12
13
|
import { determineSupportedPlaybackRateValues } from './functions/determine-supported-playback-rate-values';
|
|
13
14
|
import { pause } from './functions/pause';
|
|
14
15
|
import { play } from './functions/play';
|
|
16
|
+
import { updateVectorWithNewPosition } from './functions/update-vector-with-new-position';
|
|
15
17
|
export { createSetTimingsrc };
|
|
16
18
|
export { createUpdateGradually };
|
|
17
19
|
export const createUpdateStepwise = createUpdateStepwiseFactory(translateTimingStateVector);
|
|
18
20
|
const updateMediaElement = createUpdateMediaElement(pause, play, createSetCurrentTime(new WeakMap()), createSetPlaybackRate(new WeakMap()));
|
|
19
21
|
export const setTimingsrcWithCustomUpdateFunction = createSetTimingsrcWithCustomUpdateFunction(animationFrame, document, on, updateMediaElement);
|
|
20
|
-
export const setTimingsrc = createDefaultSetTimingsrc(createSetTimingsrc, createUpdateGradually, createUpdateStepwise, determineSupportedPlaybackRateValues, setTimingsrcWithCustomUpdateFunction, createWindow());
|
|
22
|
+
export const setTimingsrc = createDefaultSetTimingsrc(createComputeVelocity, createSetTimingsrc, createUpdateGradually, createUpdateStepwise, determineSupportedPlaybackRateValues, setTimingsrcWithCustomUpdateFunction, updateVectorWithNewPosition, createWindow());
|
|
21
23
|
//# sourceMappingURL=module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../src/module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,EAAE,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,0CAA0C,EAAE,MAAM,uDAAuD,CAAC;AACnH,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAClF,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,oCAAoC,EAAE,MAAM,sDAAsD,CAAC;AAC5G,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../src/module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,EAAE,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,0CAA0C,EAAE,MAAM,uDAAuD,CAAC;AACnH,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAClF,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,oCAAoC,EAAE,MAAM,sDAAsD,CAAC;AAC5G,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,2BAA2B,EAAE,MAAM,6CAA6C,CAAC;AAE1F,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAE9B,OAAO,EAAE,qBAAqB,EAAE,CAAC;AAEjC,MAAM,CAAC,MAAM,oBAAoB,GAAG,2BAA2B,CAAC,0BAA0B,CAAC,CAAC;AAE5F,MAAM,kBAAkB,GAAG,wBAAwB,CAAC,KAAK,EAAE,IAAI,EAAE,oBAAoB,CAAC,IAAI,OAAO,EAAE,CAAC,EAAE,qBAAqB,CAAC,IAAI,OAAO,EAAE,CAAC,CAAC,CAAC;AAE5I,MAAM,CAAC,MAAM,oCAAoC,GAAG,0CAA0C,CAC1F,cAAc,EACd,QAAQ,EACR,EAAE,EACF,kBAAkB,CACrB,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,yBAAyB,CACjD,qBAAqB,EACrB,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACpB,oCAAoC,EACpC,oCAAoC,EACpC,2BAA2B,EAC3B,YAAY,EAAE,CACjB,CAAC"}
|
|
@@ -1,20 +1,4 @@
|
|
|
1
|
-
export * from './default-timingsrc-factory';
|
|
2
|
-
export * from './determine-supported-playback-rate-values-function';
|
|
3
|
-
export * from './pause-function';
|
|
4
|
-
export * from './play-function';
|
|
5
1
|
export * from './prepare-timing-state-vector-function';
|
|
6
|
-
export * from './set-current-time-factory';
|
|
7
|
-
export * from './set-current-time-function';
|
|
8
|
-
export * from './set-playback-rate-factory';
|
|
9
|
-
export * from './set-playback-rate-function';
|
|
10
|
-
export * from './set-timingsrc-factory';
|
|
11
|
-
export * from './set-timingsrc-function';
|
|
12
|
-
export * from './set-timingsrc-with-custom-update-function-factory';
|
|
13
|
-
export * from './set-timingsrc-with-custom-update-function-function';
|
|
14
2
|
export * from './update-function';
|
|
15
|
-
export * from './update-
|
|
16
|
-
export * from './update-media-element-factory';
|
|
17
|
-
export * from './update-stepwise-factory';
|
|
18
|
-
export * from './update-stepwise-factory-factory';
|
|
19
|
-
export * from './window-factory';
|
|
3
|
+
export * from './update-vector-with-custom-state';
|
|
20
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,wCAAwC,CAAC;AACvD,cAAc,mBAAmB,CAAC;AAClC,cAAc,mCAAmC,CAAC"}
|
|
@@ -1,20 +1,4 @@
|
|
|
1
|
-
export * from './default-timingsrc-factory';
|
|
2
|
-
export * from './determine-supported-playback-rate-values-function';
|
|
3
|
-
export * from './pause-function';
|
|
4
|
-
export * from './play-function';
|
|
5
1
|
export * from './prepare-timing-state-vector-function';
|
|
6
|
-
export * from './set-current-time-factory';
|
|
7
|
-
export * from './set-current-time-function';
|
|
8
|
-
export * from './set-playback-rate-factory';
|
|
9
|
-
export * from './set-playback-rate-function';
|
|
10
|
-
export * from './set-timingsrc-factory';
|
|
11
|
-
export * from './set-timingsrc-function';
|
|
12
|
-
export * from './set-timingsrc-with-custom-update-function-factory';
|
|
13
|
-
export * from './set-timingsrc-with-custom-update-function-function';
|
|
14
2
|
export * from './update-function';
|
|
15
|
-
export * from './update-
|
|
16
|
-
export * from './update-media-element-factory';
|
|
17
|
-
export * from './update-stepwise-factory';
|
|
18
|
-
export * from './update-stepwise-factory-factory';
|
|
19
|
-
export * from './window-factory';
|
|
3
|
+
export * from './update-vector-with-custom-state';
|
|
20
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,wCAAwC,CAAC;AACvD,cAAc,mBAAmB,CAAC;AAClC,cAAc,mCAAmC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ITimingStateVector } from 'timing-object';
|
|
2
2
|
import { IUpdateVector } from '../interfaces';
|
|
3
|
-
export declare type TUpdateFunction = (timingStateVector: ITimingStateVector, currentTime: number) =>
|
|
3
|
+
export declare type TUpdateFunction<UpdateVectorWithCustomState extends IUpdateVector> = (timingStateVector: ITimingStateVector, currentTime: number, previousUpdateVectorWithCustomState: null | UpdateVectorWithCustomState) => UpdateVectorWithCustomState;
|
|
4
4
|
//# sourceMappingURL=update-function.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-function.d.ts","sourceRoot":"","sources":["../../../src/types/update-function.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,oBAAY,eAAe,
|
|
1
|
+
{"version":3,"file":"update-function.d.ts","sourceRoot":"","sources":["../../../src/types/update-function.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,oBAAY,eAAe,CAAC,2BAA2B,SAAS,aAAa,IAAI,CAC7E,iBAAiB,EAAE,kBAAkB,EACrC,WAAW,EAAE,MAAM,EACnB,mCAAmC,EAAE,IAAI,GAAG,2BAA2B,KACtE,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { TUpdateFunction } from './update-function';
|
|
2
|
+
export declare type TUpdateVectorWithCustomState<UpdateFunction> = UpdateFunction extends TUpdateFunction<infer UpdateVectorWithCustomState> ? UpdateVectorWithCustomState : never;
|
|
3
|
+
//# sourceMappingURL=update-vector-with-custom-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-vector-with-custom-state.d.ts","sourceRoot":"","sources":["../../../src/types/update-vector-with-custom-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,oBAAY,4BAA4B,CAAC,cAAc,IAAI,cAAc,SAAS,eAAe,CAAC,MAAM,2BAA2B,CAAC,GAC9H,2BAA2B,GAC3B,KAAK,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-vector-with-custom-state.js","sourceRoot":"","sources":["../../../src/types/update-vector-with-custom-state.ts"],"names":[],"mappings":""}
|
package/build/es5/bundle.js
CHANGED
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('subscribable-things'), require('timing-object'), require('@babel/runtime/helpers/slicedToArray')
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'subscribable-things', 'timing-object', '@babel/runtime/helpers/slicedToArray'
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.timingsrc = {}, global.subscribableThings, global.timingObject, global._slicedToArray
|
|
5
|
-
})(this, (function (exports, subscribableThings, timingObject, _slicedToArray
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('subscribable-things'), require('timing-object'), require('@babel/runtime/helpers/slicedToArray')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'subscribable-things', 'timing-object', '@babel/runtime/helpers/slicedToArray'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.timingsrc = {}, global.subscribableThings, global.timingObject, global._slicedToArray));
|
|
5
|
+
})(this, (function (exports, subscribableThings, timingObject, _slicedToArray) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
9
9
|
var _slicedToArray__default = /*#__PURE__*/_interopDefaultLegacy(_slicedToArray);
|
|
10
|
-
|
|
10
|
+
|
|
11
|
+
var createComputeVelocity = function createComputeVelocity(timeConstant) {
|
|
12
|
+
return function (delta, minValue, maxValue, velocity) {
|
|
13
|
+
return Math.max(minValue, Math.min(maxValue, (timeConstant - delta) / timeConstant * velocity));
|
|
14
|
+
};
|
|
15
|
+
};
|
|
11
16
|
|
|
12
17
|
var DEFAULT_THRESHOLD = 1;
|
|
13
18
|
var DEFAULT_TIME_CONSTANT = 0.5;
|
|
14
19
|
var DEFAULT_TOLERANCE = 0.025;
|
|
15
|
-
var createDefaultSetTimingsrc = function createDefaultSetTimingsrc(createSetTimingsrc, createUpdateGradually, createUpdateStepwise, determineSupportedPlaybackRateValues, setTimingsrcWithCustomUpdateFunction, window) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
} : createSetTimingsrc(setTimingsrcWithCustomUpdateFunction, createUpdateGradually(determineSupportedPlaybackRateValues(window), DEFAULT_TIME_CONSTANT, DEFAULT_THRESHOLD, DEFAULT_TOLERANCE));
|
|
20
|
+
var createDefaultSetTimingsrc = function createDefaultSetTimingsrc(createComputeVelocity, createSetTimingsrc, createUpdateGradually, createUpdateStepwise, determineSupportedPlaybackRateValues, setTimingsrcWithCustomUpdateFunction, updateVectorWithNewPosition, window) {
|
|
21
|
+
var update = window !== null && window.navigator.userAgent.includes('Safari') && !window.navigator.userAgent.includes('Chrome') ? createUpdateStepwise(DEFAULT_TOLERANCE) : createUpdateGradually(createComputeVelocity(DEFAULT_TIME_CONSTANT), determineSupportedPlaybackRateValues(window), DEFAULT_THRESHOLD, DEFAULT_TOLERANCE, updateVectorWithNewPosition);
|
|
22
|
+
return createSetTimingsrc(setTimingsrcWithCustomUpdateFunction, update);
|
|
19
23
|
};
|
|
20
24
|
|
|
21
25
|
var createSetCurrentTime = function createSetCurrentTime(currentTimeAssignments) {
|
|
@@ -52,47 +56,79 @@
|
|
|
52
56
|
var createSetTimingsrcWithCustomUpdateFunction = function createSetTimingsrcWithCustomUpdateFunction(animationFrame, document, on, updateMediaElement) {
|
|
53
57
|
return function (mediaElement, timingObject, updateFunction) {
|
|
54
58
|
var prepareTimingStateVector = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
|
|
59
|
+
var previousUpdateVectorWithCustomState = null;
|
|
55
60
|
|
|
56
61
|
var update = function update() {
|
|
57
62
|
var currentTime = mediaElement.currentTime,
|
|
58
63
|
duration = mediaElement.duration,
|
|
59
64
|
playbackRate = mediaElement.playbackRate;
|
|
60
65
|
var timingStateVector = timingObject.query();
|
|
61
|
-
|
|
62
|
-
var _updateFunction = updateFunction(prepareTimingStateVector === null ? timingStateVector : prepareTimingStateVector(timingStateVector), currentTime),
|
|
63
|
-
position = _updateFunction.position,
|
|
64
|
-
velocity = _updateFunction.velocity;
|
|
65
|
-
|
|
66
|
+
previousUpdateVectorWithCustomState = updateFunction(prepareTimingStateVector === null ? timingStateVector : prepareTimingStateVector(timingStateVector), currentTime, previousUpdateVectorWithCustomState);
|
|
66
67
|
var sanitizedDuration = typeof duration === 'number' && !isNaN(duration) ? duration : 0;
|
|
68
|
+
var _previousUpdateVector = previousUpdateVectorWithCustomState,
|
|
69
|
+
position = _previousUpdateVector.position,
|
|
70
|
+
velocity = _previousUpdateVector.velocity;
|
|
67
71
|
updateMediaElement(currentTime, sanitizedDuration, mediaElement, playbackRate, position, velocity);
|
|
72
|
+
return velocity !== 0;
|
|
68
73
|
};
|
|
69
74
|
|
|
70
|
-
var
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
if (
|
|
74
|
-
|
|
75
|
+
var unsubscribe;
|
|
76
|
+
|
|
77
|
+
var updateOnce = function updateOnce() {
|
|
78
|
+
if (!update()) {
|
|
79
|
+
unsubscribe();
|
|
80
|
+
unsubscribe = updateReactively();
|
|
75
81
|
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
var updateConsistently = function updateConsistently() {
|
|
85
|
+
var unsubscribeFunctions = [animationFrame()(function () {
|
|
86
|
+
return updateOnce();
|
|
87
|
+
}), on(timingObject, 'change')(function () {
|
|
88
|
+
if (document.visibilityState === 'hidden') {
|
|
89
|
+
updateOnce();
|
|
90
|
+
}
|
|
91
|
+
})];
|
|
92
|
+
return function () {
|
|
93
|
+
return unsubscribeFunctions.forEach(function (unsubscribeFunction) {
|
|
94
|
+
return unsubscribeFunction();
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
var updateReactively = function updateReactively() {
|
|
100
|
+
return on(timingObject, 'change')(function () {
|
|
101
|
+
if (update()) {
|
|
102
|
+
unsubscribe();
|
|
103
|
+
unsubscribe = updateConsistently();
|
|
104
|
+
}
|
|
80
105
|
});
|
|
81
106
|
};
|
|
107
|
+
|
|
108
|
+
unsubscribe = update() ? updateConsistently() : updateReactively();
|
|
109
|
+
return function () {
|
|
110
|
+
return unsubscribe();
|
|
111
|
+
};
|
|
82
112
|
};
|
|
83
113
|
};
|
|
84
114
|
|
|
85
|
-
var createUpdateGradually = function createUpdateGradually(
|
|
115
|
+
var createUpdateGradually = function createUpdateGradually(computeVelocity, _ref, threshold, tolerance, updateVectorWithNewPosition) {
|
|
86
116
|
var _ref2 = _slicedToArray__default["default"](_ref, 2),
|
|
87
117
|
minValue = _ref2[0],
|
|
88
118
|
maxValue = _ref2[1];
|
|
89
119
|
|
|
90
|
-
return function (_ref3, currentTime) {
|
|
120
|
+
return function (_ref3, currentTime, previousUpdateVectorWithCustomState) {
|
|
91
121
|
var position = _ref3.position,
|
|
92
122
|
velocity = _ref3.velocity;
|
|
93
123
|
|
|
124
|
+
var _ref4 = previousUpdateVectorWithCustomState !== null && previousUpdateVectorWithCustomState !== void 0 ? previousUpdateVectorWithCustomState : {
|
|
125
|
+
mediaElementDelay: 0
|
|
126
|
+
},
|
|
127
|
+
mediaElementDelay = _ref4.mediaElementDelay;
|
|
128
|
+
|
|
94
129
|
if (velocity < minValue || velocity > maxValue) {
|
|
95
130
|
return {
|
|
131
|
+
mediaElementDelay: mediaElementDelay,
|
|
96
132
|
position: position,
|
|
97
133
|
velocity: 0
|
|
98
134
|
};
|
|
@@ -100,6 +136,7 @@
|
|
|
100
136
|
|
|
101
137
|
if (position < 0 || velocity === 0) {
|
|
102
138
|
return {
|
|
139
|
+
mediaElementDelay: mediaElementDelay,
|
|
103
140
|
position: position,
|
|
104
141
|
velocity: velocity
|
|
105
142
|
};
|
|
@@ -109,20 +146,38 @@
|
|
|
109
146
|
var absolutePositionDifference = Math.abs(positionDifference);
|
|
110
147
|
|
|
111
148
|
if (absolutePositionDifference > threshold) {
|
|
112
|
-
|
|
113
|
-
position:
|
|
114
|
-
|
|
115
|
-
|
|
149
|
+
var _ref5 = previousUpdateVectorWithCustomState !== null && previousUpdateVectorWithCustomState !== void 0 ? previousUpdateVectorWithCustomState : {
|
|
150
|
+
position: null
|
|
151
|
+
},
|
|
152
|
+
lastPosition = _ref5.position;
|
|
153
|
+
|
|
154
|
+
if (positionDifference < 0 || positionDifference > mediaElementDelay) {
|
|
155
|
+
if (lastPosition === currentTime) {
|
|
156
|
+
mediaElementDelay += absolutePositionDifference;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return updateVectorWithNewPosition(mediaElementDelay, position, function (nextPosition) {
|
|
160
|
+
return computeVelocity(nextPosition - position, minValue, maxValue, velocity);
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (lastPosition !== currentTime) {
|
|
165
|
+
return updateVectorWithNewPosition(mediaElementDelay - absolutePositionDifference, position, function (nextPosition) {
|
|
166
|
+
return computeVelocity(nextPosition - position, minValue, maxValue, velocity);
|
|
167
|
+
});
|
|
168
|
+
}
|
|
116
169
|
}
|
|
117
170
|
|
|
118
171
|
if (absolutePositionDifference > tolerance) {
|
|
119
172
|
return {
|
|
173
|
+
mediaElementDelay: mediaElementDelay,
|
|
120
174
|
position: currentTime,
|
|
121
|
-
velocity:
|
|
175
|
+
velocity: computeVelocity(positionDifference, minValue, maxValue, velocity)
|
|
122
176
|
};
|
|
123
177
|
}
|
|
124
178
|
|
|
125
179
|
return {
|
|
180
|
+
mediaElementDelay: mediaElementDelay,
|
|
126
181
|
position: currentTime,
|
|
127
182
|
velocity: velocity
|
|
128
183
|
};
|
|
@@ -166,67 +221,133 @@
|
|
|
166
221
|
};
|
|
167
222
|
};
|
|
168
223
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
172
|
-
|
|
224
|
+
var MAXIMUM_PLAYHEAD_DIFFERENCE = 0.5;
|
|
173
225
|
var createUpdateStepwiseFactory = function createUpdateStepwiseFactory(translateTimingStateVector) {
|
|
174
226
|
return function (tolerance) {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
227
|
+
return function (timingStateVector, currentTime, previousUpdateVectorWithCustomState) {
|
|
228
|
+
var _ref = previousUpdateVectorWithCustomState !== null && previousUpdateVectorWithCustomState !== void 0 ? previousUpdateVectorWithCustomState : {
|
|
229
|
+
lastAppliedPostion: 0,
|
|
230
|
+
lastAppliedTimestamp: 0,
|
|
231
|
+
lastAppliedVelocity: 0,
|
|
232
|
+
lastPlayheadDifference: 0,
|
|
233
|
+
mediaElementDelay: 0,
|
|
234
|
+
numberOfDetectedResets: 0,
|
|
235
|
+
numberOfExpectedResets: 1
|
|
236
|
+
},
|
|
237
|
+
lastAppliedPostion = _ref.lastAppliedPostion,
|
|
238
|
+
lastAppliedTimestamp = _ref.lastAppliedTimestamp,
|
|
239
|
+
lastAppliedVelocity = _ref.lastAppliedVelocity,
|
|
240
|
+
lastPlayheadDifference = _ref.lastPlayheadDifference,
|
|
241
|
+
mediaElementDelay = _ref.mediaElementDelay,
|
|
242
|
+
numberOfDetectedResets = _ref.numberOfDetectedResets,
|
|
243
|
+
numberOfExpectedResets = _ref.numberOfExpectedResets;
|
|
244
|
+
|
|
179
245
|
if (timingStateVector.position < 0 || timingStateVector.velocity === 0) {
|
|
180
|
-
|
|
246
|
+
lastAppliedPostion = timingStateVector.position;
|
|
247
|
+
lastAppliedVelocity = timingStateVector.velocity;
|
|
181
248
|
return {
|
|
182
|
-
|
|
183
|
-
|
|
249
|
+
lastAppliedPostion: lastAppliedPostion,
|
|
250
|
+
lastAppliedTimestamp: 0,
|
|
251
|
+
lastAppliedVelocity: lastAppliedVelocity,
|
|
252
|
+
lastPlayheadDifference: lastPlayheadDifference,
|
|
253
|
+
mediaElementDelay: mediaElementDelay,
|
|
254
|
+
numberOfDetectedResets: numberOfDetectedResets,
|
|
255
|
+
numberOfExpectedResets: numberOfExpectedResets,
|
|
256
|
+
position: lastAppliedPostion,
|
|
257
|
+
velocity: lastAppliedVelocity
|
|
184
258
|
};
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
259
|
+
} // Bug #4: Safari decreases currentTime after playing for about 200 milliseconds.
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
if (lastAppliedVelocity === timingStateVector.velocity && lastPlayheadDifference < MAXIMUM_PLAYHEAD_DIFFERENCE) {
|
|
263
|
+
var playheadDifference = Math.abs(currentTime - lastAppliedPostion) * lastAppliedVelocity;
|
|
264
|
+
|
|
265
|
+
if (playheadDifference < MAXIMUM_PLAYHEAD_DIFFERENCE) {
|
|
266
|
+
if (playheadDifference + 0.001 > lastPlayheadDifference) {
|
|
267
|
+
lastPlayheadDifference = playheadDifference;
|
|
268
|
+
|
|
269
|
+
if (numberOfDetectedResets < numberOfExpectedResets) {
|
|
270
|
+
return {
|
|
271
|
+
lastAppliedPostion: lastAppliedPostion,
|
|
272
|
+
lastAppliedTimestamp: lastAppliedTimestamp,
|
|
273
|
+
lastAppliedVelocity: lastAppliedVelocity,
|
|
274
|
+
lastPlayheadDifference: lastPlayheadDifference,
|
|
275
|
+
mediaElementDelay: mediaElementDelay,
|
|
276
|
+
numberOfDetectedResets: numberOfDetectedResets,
|
|
277
|
+
numberOfExpectedResets: numberOfExpectedResets,
|
|
278
|
+
position: currentTime,
|
|
279
|
+
velocity: lastAppliedVelocity
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
} else {
|
|
283
|
+
lastPlayheadDifference = playheadDifference;
|
|
284
|
+
numberOfDetectedResets += 1;
|
|
285
|
+
|
|
286
|
+
if (numberOfDetectedResets <= numberOfExpectedResets) {
|
|
287
|
+
return {
|
|
288
|
+
lastAppliedPostion: lastAppliedPostion,
|
|
289
|
+
lastAppliedTimestamp: lastAppliedTimestamp,
|
|
290
|
+
lastAppliedVelocity: lastAppliedVelocity,
|
|
291
|
+
lastPlayheadDifference: lastPlayheadDifference,
|
|
292
|
+
mediaElementDelay: mediaElementDelay,
|
|
293
|
+
numberOfDetectedResets: numberOfDetectedResets,
|
|
294
|
+
numberOfExpectedResets: numberOfExpectedResets,
|
|
295
|
+
position: currentTime,
|
|
296
|
+
velocity: lastAppliedVelocity
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
numberOfExpectedResets += 1;
|
|
301
|
+
}
|
|
302
|
+
} else {
|
|
191
303
|
lastPlayheadDifference = playheadDifference;
|
|
192
|
-
|
|
193
|
-
position: currentTime,
|
|
194
|
-
velocity: lastMotionUpdate.velocity
|
|
195
|
-
};
|
|
304
|
+
numberOfExpectedResets = Math.max(numberOfDetectedResets, 1);
|
|
196
305
|
}
|
|
197
|
-
|
|
198
|
-
|
|
306
|
+
} else {
|
|
307
|
+
lastAppliedTimestamp = 0;
|
|
199
308
|
}
|
|
200
309
|
|
|
201
310
|
var positionDifference = Math.abs(currentTime - timingStateVector.position);
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
311
|
+
var velocityHasChanged = lastAppliedVelocity === 0 || lastAppliedVelocity < 0 && timingStateVector.velocity > 0 || lastAppliedVelocity > 0 && timingStateVector.velocity < 0;
|
|
312
|
+
|
|
313
|
+
if (positionDifference > tolerance || velocityHasChanged) {
|
|
314
|
+
if (lastAppliedTimestamp > 0) {
|
|
315
|
+
var elapsedTime = timingStateVector.timestamp - lastAppliedTimestamp;
|
|
316
|
+
|
|
317
|
+
var _translateTimingState = translateTimingStateVector({
|
|
318
|
+
acceleration: 0,
|
|
319
|
+
position: lastAppliedPostion,
|
|
320
|
+
timestamp: lastAppliedTimestamp,
|
|
321
|
+
velocity: lastAppliedVelocity
|
|
322
|
+
}, elapsedTime),
|
|
210
323
|
position = _translateTimingState.position;
|
|
211
324
|
|
|
212
325
|
mediaElementDelay = position - currentTime;
|
|
213
326
|
}
|
|
214
327
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
position: positioWithDelay,
|
|
218
|
-
timestamp: timingStateVector.timestamp,
|
|
219
|
-
velocity: timingStateVector.velocity
|
|
220
|
-
};
|
|
221
|
-
lastPlayheadDifference = 0;
|
|
328
|
+
lastAppliedPostion = timingStateVector.position + mediaElementDelay;
|
|
329
|
+
lastAppliedVelocity = timingStateVector.velocity;
|
|
222
330
|
return {
|
|
223
|
-
|
|
224
|
-
|
|
331
|
+
lastAppliedPostion: lastAppliedPostion,
|
|
332
|
+
lastAppliedTimestamp: timingStateVector.timestamp,
|
|
333
|
+
lastAppliedVelocity: lastAppliedVelocity,
|
|
334
|
+
lastPlayheadDifference: 0,
|
|
335
|
+
mediaElementDelay: mediaElementDelay,
|
|
336
|
+
numberOfDetectedResets: 0,
|
|
337
|
+
numberOfExpectedResets: numberOfExpectedResets,
|
|
338
|
+
position: lastAppliedPostion,
|
|
339
|
+
velocity: lastAppliedVelocity
|
|
225
340
|
};
|
|
226
341
|
}
|
|
227
342
|
|
|
228
|
-
lastMotionUpdate = null;
|
|
229
343
|
return {
|
|
344
|
+
lastAppliedPostion: lastAppliedPostion,
|
|
345
|
+
lastAppliedTimestamp: lastAppliedTimestamp,
|
|
346
|
+
lastAppliedVelocity: lastAppliedVelocity,
|
|
347
|
+
lastPlayheadDifference: lastPlayheadDifference,
|
|
348
|
+
mediaElementDelay: mediaElementDelay,
|
|
349
|
+
numberOfDetectedResets: numberOfDetectedResets,
|
|
350
|
+
numberOfExpectedResets: numberOfExpectedResets,
|
|
230
351
|
position: currentTime,
|
|
231
352
|
velocity: timingStateVector.velocity
|
|
232
353
|
};
|
|
@@ -278,10 +399,19 @@
|
|
|
278
399
|
}
|
|
279
400
|
};
|
|
280
401
|
|
|
402
|
+
var updateVectorWithNewPosition = function updateVectorWithNewPosition(mediaElementDelay, position, updateVelocity) {
|
|
403
|
+
var nextPosition = position + mediaElementDelay;
|
|
404
|
+
return {
|
|
405
|
+
mediaElementDelay: mediaElementDelay,
|
|
406
|
+
position: nextPosition,
|
|
407
|
+
velocity: updateVelocity(nextPosition)
|
|
408
|
+
};
|
|
409
|
+
};
|
|
410
|
+
|
|
281
411
|
var createUpdateStepwise = createUpdateStepwiseFactory(timingObject.translateTimingStateVector);
|
|
282
412
|
var updateMediaElement = createUpdateMediaElement(pause, play, createSetCurrentTime(new WeakMap()), createSetPlaybackRate(new WeakMap()));
|
|
283
413
|
var setTimingsrcWithCustomUpdateFunction = createSetTimingsrcWithCustomUpdateFunction(subscribableThings.animationFrame, document, subscribableThings.on, updateMediaElement);
|
|
284
|
-
var setTimingsrc = createDefaultSetTimingsrc(createSetTimingsrc, createUpdateGradually, createUpdateStepwise, determineSupportedPlaybackRateValues, setTimingsrcWithCustomUpdateFunction, createWindow());
|
|
414
|
+
var setTimingsrc = createDefaultSetTimingsrc(createComputeVelocity, createSetTimingsrc, createUpdateGradually, createUpdateStepwise, determineSupportedPlaybackRateValues, setTimingsrcWithCustomUpdateFunction, updateVectorWithNewPosition, createWindow());
|
|
285
415
|
|
|
286
416
|
exports.createSetTimingsrc = createSetTimingsrc;
|
|
287
417
|
exports.createUpdateGradually = createUpdateGradually;
|
package/package.json
CHANGED
|
@@ -16,23 +16,23 @@
|
|
|
16
16
|
},
|
|
17
17
|
"description": "A library to synchronize a MediaElement with a TimingObject.",
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@babel/core": "^7.19.
|
|
19
|
+
"@babel/core": "^7.19.1",
|
|
20
20
|
"@babel/plugin-external-helpers": "^7.18.6",
|
|
21
|
-
"@babel/plugin-transform-runtime": "^7.
|
|
22
|
-
"@babel/preset-env": "^7.19.
|
|
21
|
+
"@babel/plugin-transform-runtime": "^7.19.1",
|
|
22
|
+
"@babel/preset-env": "^7.19.1",
|
|
23
23
|
"@commitlint/cli": "^17.1.2",
|
|
24
24
|
"@commitlint/config-angular": "^17.1.0",
|
|
25
25
|
"@rollup/plugin-babel": "^5.3.1",
|
|
26
26
|
"chai": "^4.3.6",
|
|
27
27
|
"commitizen": "^4.2.5",
|
|
28
28
|
"cz-conventional-changelog": "^3.3.0",
|
|
29
|
-
"eslint": "^8.23.
|
|
29
|
+
"eslint": "^8.23.1",
|
|
30
30
|
"eslint-config-holy-grail": "^52.0.33",
|
|
31
31
|
"grunt": "^1.5.3",
|
|
32
32
|
"grunt-cli": "^1.4.3",
|
|
33
33
|
"grunt-sh": "^0.2.0",
|
|
34
34
|
"husky": "^8.0.1",
|
|
35
|
-
"karma": "^6.4.
|
|
35
|
+
"karma": "^6.4.1",
|
|
36
36
|
"karma-browserstack-launcher": "^1.6.0",
|
|
37
37
|
"karma-chrome-launcher": "^3.1.1",
|
|
38
38
|
"karma-firefox-launcher": "^2.1.2",
|
|
@@ -45,10 +45,10 @@
|
|
|
45
45
|
"prettier": "^2.7.1",
|
|
46
46
|
"pretty-quick": "^3.1.3",
|
|
47
47
|
"rimraf": "^3.0.2",
|
|
48
|
-
"rollup": "^2.79.
|
|
48
|
+
"rollup": "^2.79.1",
|
|
49
49
|
"sinon": "^14.0.0",
|
|
50
50
|
"sinon-chai": "^3.7.0",
|
|
51
|
-
"ts-loader": "^9.
|
|
51
|
+
"ts-loader": "^9.4.1",
|
|
52
52
|
"tsconfig-holy-grail": "^11.1.36",
|
|
53
53
|
"tslint": "^6.1.3",
|
|
54
54
|
"tslint-config-holy-grail": "^53.2.33",
|
|
@@ -75,5 +75,5 @@
|
|
|
75
75
|
"test": "grunt lint && grunt test"
|
|
76
76
|
},
|
|
77
77
|
"types": "build/es2019/module.d.ts",
|
|
78
|
-
"version": "1.2.
|
|
78
|
+
"version": "1.2.8"
|
|
79
79
|
}
|
|
@@ -1,26 +1,37 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { determineSupportedPlaybackRateValues as determineSupportedPlaybackRateValuesFunction } from '../functions/determine-supported-playback-rate-values';
|
|
2
|
+
import type { updateVectorWithNewPosition as updateVectorWithNewPositionFunction } from '../functions/update-vector-with-new-position';
|
|
3
|
+
import { TUpdateFunction, TUpdateVectorWithCustomState } from '../types';
|
|
4
|
+
import type { createComputeVelocity as createComputeVelocityFunction } from './compute-velocity';
|
|
5
|
+
import type { createSetTimingsrc as createSetTimingsrcFunction } from './set-timingsrc';
|
|
6
|
+
import type { createSetTimingsrcWithCustomUpdateFunction } from './set-timingsrc-with-custom-update-function';
|
|
7
|
+
import type { createUpdateGradually as createUpdateGraduallyFunction } from './update-gradually';
|
|
8
|
+
import type { createUpdateStepwiseFactory } from './update-stepwise-factory';
|
|
9
|
+
import type { createWindow } from './window';
|
|
2
10
|
|
|
3
11
|
const DEFAULT_THRESHOLD = 1;
|
|
4
12
|
const DEFAULT_TIME_CONSTANT = 0.5;
|
|
5
13
|
const DEFAULT_TOLERANCE = 0.025;
|
|
6
14
|
|
|
7
|
-
export const createDefaultSetTimingsrc
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
window
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
export const createDefaultSetTimingsrc = (
|
|
16
|
+
createComputeVelocity: typeof createComputeVelocityFunction,
|
|
17
|
+
createSetTimingsrc: typeof createSetTimingsrcFunction,
|
|
18
|
+
createUpdateGradually: typeof createUpdateGraduallyFunction,
|
|
19
|
+
createUpdateStepwise: ReturnType<typeof createUpdateStepwiseFactory>,
|
|
20
|
+
determineSupportedPlaybackRateValues: typeof determineSupportedPlaybackRateValuesFunction,
|
|
21
|
+
setTimingsrcWithCustomUpdateFunction: ReturnType<typeof createSetTimingsrcWithCustomUpdateFunction>,
|
|
22
|
+
updateVectorWithNewPosition: typeof updateVectorWithNewPositionFunction,
|
|
23
|
+
window: ReturnType<typeof createWindow>
|
|
24
|
+
) => {
|
|
25
|
+
const update =
|
|
26
|
+
window !== null && window.navigator.userAgent.includes('Safari') && !window.navigator.userAgent.includes('Chrome')
|
|
27
|
+
? createUpdateStepwise(DEFAULT_TOLERANCE)
|
|
28
|
+
: createUpdateGradually(
|
|
29
|
+
createComputeVelocity(DEFAULT_TIME_CONSTANT),
|
|
21
30
|
determineSupportedPlaybackRateValues(window),
|
|
22
|
-
DEFAULT_TIME_CONSTANT,
|
|
23
31
|
DEFAULT_THRESHOLD,
|
|
24
|
-
DEFAULT_TOLERANCE
|
|
25
|
-
|
|
26
|
-
|
|
32
|
+
DEFAULT_TOLERANCE,
|
|
33
|
+
updateVectorWithNewPosition
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
return createSetTimingsrc(setTimingsrcWithCustomUpdateFunction, <TUpdateFunction<TUpdateVectorWithCustomState<typeof update>>>update);
|
|
37
|
+
};
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export const createSetCurrentTime: TSetCurrentTimeFactory = (currentTimeAssignments) => {
|
|
4
|
-
return (mediaElement, previousValue, nextValue) => {
|
|
1
|
+
export const createSetCurrentTime = (currentTimeAssignments: WeakMap<HTMLMediaElement, [number, number]>) => {
|
|
2
|
+
return (mediaElement: HTMLMediaElement, previousValue: number, nextValue: number) => {
|
|
5
3
|
const currentTimeAssignment = currentTimeAssignments.get(mediaElement);
|
|
6
4
|
|
|
7
5
|
if (
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export const createSetPlaybackRate: TSetPlaybackRateFactory = (playbackRateAssignments) => {
|
|
4
|
-
return (mediaElement, previousValue, nextValue) => {
|
|
1
|
+
export const createSetPlaybackRate = (playbackRateAssignments: WeakMap<HTMLMediaElement, [number, number]>) => {
|
|
2
|
+
return (mediaElement: HTMLMediaElement, previousValue: number, nextValue: number) => {
|
|
5
3
|
const playbackRateAssignment = playbackRateAssignments.get(mediaElement);
|
|
6
4
|
|
|
7
5
|
if (
|