@vkontakte/videoplayer-core 2.0.62 → 2.0.63

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vkontakte/videoplayer-core",
3
- "version": "2.0.62",
3
+ "version": "2.0.63",
4
4
  "author": "vk.com",
5
5
  "description": "Videoplayer core library based on the vk.com platform",
6
6
  "homepage": "https://vk.com",
@@ -58,6 +58,7 @@ export interface IProviderOutput {
58
58
  error$: ISubject<IError>;
59
59
  endedEvent$: ISubject<void>;
60
60
  loopedEvent$: ISubject<Seconds>;
61
- firstBytesEvent$: ISubject<number>;
62
- firstFrameEvent$: ISubject<number>;
61
+ firstBytesEvent$: ISubject<void>;
62
+ firstFrameEvent$: ISubject<void>;
63
+ canplay$: ISubject<void>;
63
64
  }
@@ -15,6 +15,7 @@ export default class Player implements IPlayer {
15
15
  private tuning;
16
16
  private throughputEstimator;
17
17
  private isPlaybackStarted;
18
+ private initedAt;
18
19
  private desiredState;
19
20
  info: {
20
21
  playbackState$: ValueSubject<PlaybackState>;
@@ -52,6 +53,7 @@ export default class Player implements IPlayer {
52
53
  } | undefined>;
53
54
  };
54
55
  events: {
56
+ inited$: Subject<void>;
55
57
  started$: Subject<boolean>;
56
58
  startAttempt$: Subject<StartStatus>;
57
59
  willPause$: Subject<void>;
@@ -67,6 +69,7 @@ export default class Player implements IPlayer {
67
69
  willSeek$: Subject<ISeekRequest>;
68
70
  firstBytes$: Subject<number>;
69
71
  firstFrame$: Subject<number>;
72
+ canplay$: Subject<number>;
70
73
  log$: Subject<ILogEntry>;
71
74
  };
72
75
  experimental: {
package/player/types.d.ts CHANGED
@@ -66,6 +66,10 @@ export interface IPlayer {
66
66
  * остальные - в момент окончания действия.
67
67
  */
68
68
  export interface IPlayerEvents {
69
+ /**
70
+ * Плеер получил ссылку и готов к взаимодействию
71
+ */
72
+ inited$: IObservable<void>;
69
73
  /**
70
74
  * Видео начало воспроизведение в первый раз
71
75
  * Соответствует первому для видео внешнему запуску воспроизведения
@@ -126,15 +130,21 @@ export interface IPlayerEvents {
126
130
  * Получен первый кусок контента от сервера раздачи видео
127
131
  * Событие поддерживается не во всех провайдерах (т.к. не все способы проигрывания видео поддерживают такой интерфейс)
128
132
  *
129
- * Содержит время в миллисекундах: сколько прошло с момента отправки запроса за видео данными (ping)
133
+ * Содержит время в миллисекундах: сколько прошло с момента инициализации
130
134
  */
131
- firstBytes$: IObservable<number>;
135
+ firstBytes$: IObservable<Milliseconds>;
132
136
  /**
133
137
  * Показан первый кадр
134
138
  *
135
- * Содержит время в миллисекундах: сколько прошло времени с момента старта воспроизведения
139
+ * Содержит время в миллисекундах: сколько прошло времени с инициализации
140
+ */
141
+ firstFrame$: IObservable<Milliseconds>;
142
+ /**
143
+ * Плеер готов начать воспроизведение
144
+ *
145
+ * Содержит время в миллисекундах: сколько прошло времени с инициализации
136
146
  */
137
- firstFrame$: IObservable<number>;
147
+ canplay$: IObservable<Milliseconds>;
138
148
  /**
139
149
  * Логи для отладки
140
150
  */
@@ -0,0 +1,135 @@
1
+ import { Milliseconds } from '@vkontakte/videoplayer-shared';
2
+ import { IRepresentation } from '../types';
3
+ interface IParams {
4
+ videoElement: HTMLVideoElement;
5
+ playerCallback: (...args: any) => void;
6
+ config: {
7
+ minBuffer: Milliseconds;
8
+ lowLatencyMinBuffer: Milliseconds;
9
+ minBufferSegments: number;
10
+ lowLatencyMinBufferSegments: number;
11
+ maxParallelRequests: number;
12
+ };
13
+ logger: (...args: any[]) => void;
14
+ }
15
+ export default class LiveDashPlayer {
16
+ private paused;
17
+ private autoQuality;
18
+ private maxAutoQuality;
19
+ private buffering;
20
+ private destroyed;
21
+ private videoPlayStarted;
22
+ private lowLatency;
23
+ private rep?;
24
+ private bitrate;
25
+ private manifest;
26
+ private bitrateSwitcher?;
27
+ private filesFetcher?;
28
+ private sourceBuffer?;
29
+ private mediaSource?;
30
+ private currentManifestEntry?;
31
+ private manifestRequest?;
32
+ private manifestRefetchTimer?;
33
+ private bufferStates;
34
+ private downloadRate?;
35
+ private sourceJitter;
36
+ private chunkRateEstimator;
37
+ private manifestUrl;
38
+ private urlResolver;
39
+ private params;
40
+ constructor(params: IParams);
41
+ attachSource(manifestUrl: string): void;
42
+ /**
43
+ * switch to auto quality
44
+ */
45
+ setAutoQualityEnabled(enabled: boolean): void;
46
+ setMaxAutoQuality(height: number | undefined): void;
47
+ /**
48
+ * switch quality by name
49
+ */
50
+ switchByName(name: string): void;
51
+ /**
52
+ * seek to actual video position
53
+ */
54
+ catchUp(): void;
55
+ stop(): void;
56
+ pause(): void;
57
+ play(onPlayNotAllowed?: () => void): void;
58
+ startPlay(targetQ: IRepresentation, autoQuality: boolean): void;
59
+ /**
60
+ * destroy player
61
+ */
62
+ destroy(): void;
63
+ reinit(newManifestUrl: string): void;
64
+ /**
65
+ * if all retries fail...
66
+ */
67
+ private _handleNetworkError;
68
+ /**
69
+ * Retry request
70
+ */
71
+ private _retryCallback;
72
+ /**
73
+ * how many seconds are there in the buffer
74
+ */
75
+ private _getBufferSizeSec;
76
+ /**
77
+ * send buffering notification to player
78
+ */
79
+ private _notifyBuffering;
80
+ /**
81
+ * initialize video tag, add necessary event listeners
82
+ * @private
83
+ */
84
+ private _initVideo;
85
+ /**
86
+ * there may be small gaps of several milliseconds when switching quality
87
+ * we jump over these gaps here
88
+ */
89
+ private _fixupStall;
90
+ /**
91
+ * return best quality for rate
92
+ */
93
+ private _selectQuality;
94
+ private shouldPlay;
95
+ /**
96
+ * set video source
97
+ */
98
+ private _setVideoSrc;
99
+ /**
100
+ * initialize player with target quality
101
+ */
102
+ private _initPlayerWith;
103
+ /**
104
+ * represents specific quality stream
105
+ */
106
+ private _representation;
107
+ /**
108
+ * switch to quality
109
+ * TODO: Если новое качество выше старого – переключиться сразу. Если хуже, доиграть буфер
110
+ */
111
+ private _switchToQuality;
112
+ /**
113
+ * check if quality is available
114
+ */
115
+ private _qualityAvailable;
116
+ /**
117
+ * analyze bitrate data and switch qualities accordingly
118
+ */
119
+ private _initBitrateSwitcher;
120
+ /**
121
+ * load and parse manifest file
122
+ */
123
+ private _fetchManifest;
124
+ private _playVideoElement;
125
+ /**
126
+ * update internal state when manifest was received from remote
127
+ */
128
+ private _handleManifestUpdate;
129
+ /**
130
+ * schedule manifest update after delay
131
+ */
132
+ private _refetchManifest;
133
+ private _initManifest;
134
+ }
135
+ export {};
@@ -0,0 +1,60 @@
1
+ import { Milliseconds } from '@vkontakte/videoplayer-shared';
2
+ import HttpVideoBuffer from "../../../utils/buffer/HttpVideoBuffer";
3
+ import { IDashConfig, IRef, IRepresentation } from '../types';
4
+ interface IParams {
5
+ video: HTMLVideoElement;
6
+ buffer: HttpVideoBuffer;
7
+ selectRepresentation: (representations: IRepresentation[]) => IRepresentation;
8
+ onManifestReady: (representations: IRepresentation[]) => void;
9
+ onIdxRequestPing: (ping: Milliseconds) => void;
10
+ onResponseHeaders: (headers: Headers) => void;
11
+ onBandwidthChange: (payload: {
12
+ size: number;
13
+ duration: number;
14
+ speed: number;
15
+ }) => void;
16
+ onRepresentationPlay: (representation: IRepresentation) => void;
17
+ onError: (id: string, message: string, thrown?: Error | unknown) => void;
18
+ config: IDashConfig;
19
+ onDashCallback?: (eventName: string, param?: any) => any;
20
+ }
21
+ export default class DashLite {
22
+ private _params;
23
+ private _representations;
24
+ private _appendVector;
25
+ private _currentRepresentation?;
26
+ private _stream;
27
+ private _lastLoadOffset?;
28
+ private _loopTimeout?;
29
+ private _cachingPaused;
30
+ private _duration;
31
+ private STREAM_END_THRESHOLD;
32
+ private _video;
33
+ private _buffer;
34
+ private _onDashCallback;
35
+ private _config;
36
+ constructor(params: IParams);
37
+ /**
38
+ * Parse duration from ISO8601 string.
39
+ * @see https://en.wikipedia.org/wiki/ISO_8601#Durations
40
+ * @see https://github.com/moment/moment/blob/develop/src/lib/duration/create.js#L13
41
+ */
42
+ _parseDurationFromISO8601(input: string): number;
43
+ getRepresentations(): IRepresentation[];
44
+ attachSource(manifestUrl: string, failoverHosts?: string[]): void;
45
+ attachManifest(manifestString: string, failoverHosts?: string[], origin?: string): void;
46
+ _loadInitAndSidx(representation: IRepresentation, cb?: () => void): void;
47
+ startPlay(representation: IRepresentation): void;
48
+ _loadRef(representation: IRepresentation, fromTime: number, needToSeek?: boolean, forcePrecise?: boolean): void;
49
+ setQualityByRepresentation(newRepresentation: IRepresentation, force?: boolean): void;
50
+ setQuality(index: number): void;
51
+ pauseCaching(): void;
52
+ resumeCaching(): void;
53
+ seek(time: number, forcePrecise?: boolean): void;
54
+ updateRefsForCurrentTime(): void;
55
+ _findRef(time: number): IRef | undefined;
56
+ _isLastRef(ref: IRef): boolean;
57
+ _findBufferRangeEnd(time: number): number;
58
+ destroy(): void;
59
+ }
60
+ export {};
@@ -31,8 +31,9 @@ export default class ProviderContainer implements IProviderContainer {
31
31
  seekedEvent$: Subject<void>;
32
32
  loopedEvent$: Subject<number>;
33
33
  endedEvent$: Subject<void>;
34
- firstBytesEvent$: Subject<number>;
35
- firstFrameEvent$: Subject<number>;
34
+ firstBytesEvent$: Subject<void>;
35
+ firstFrameEvent$: Subject<void>;
36
+ canplay$: Subject<void>;
36
37
  isLive$: ValueSubject<undefined>;
37
38
  liveTime$: ValueSubject<undefined>;
38
39
  availableTextTracks$: ValueSubject<never[]>;
@@ -1,4 +1,4 @@
1
- import { Milliseconds, Seconds, IObservable, IError } from '@vkontakte/videoplayer-shared';
1
+ import { Seconds, IObservable, IError } from '@vkontakte/videoplayer-shared';
2
2
  import { IVolumeState } from "../../player/types";
3
3
  import { IRange } from "../../utils/range";
4
4
  interface IObservableVideo {
@@ -11,15 +11,14 @@ interface IObservableVideo {
11
11
  seeked$: IObservable<undefined>;
12
12
  seeking$: IObservable<undefined>;
13
13
  progress$: IObservable<undefined>;
14
- loadedMetadata$: IObservable<undefined>;
15
- loadedData$: IObservable<undefined>;
16
14
  timeUpdate$: IObservable<Seconds>;
17
15
  durationChange$: IObservable<Seconds>;
16
+ loadStart$: IObservable<void>;
17
+ loadedMetadata$: IObservable<undefined>;
18
+ loadedData$: IObservable<undefined>;
18
19
  isBuffering$: IObservable<boolean>;
19
20
  currentBuffer$: IObservable<IRange<Seconds>>;
20
21
  volumeState$: IObservable<IVolumeState>;
21
- firstBytes$: IObservable<Milliseconds>;
22
- firstFrame$: IObservable<Milliseconds>;
23
22
  }
24
23
  export declare const observe: (video: HTMLVideoElement) => IObservableVideo;
25
24
  export {};
@@ -1,3 +0,0 @@
1
- import { IObservable, Milliseconds } from '@vkontakte/videoplayer-shared';
2
- declare const _default: (video: HTMLVideoElement) => IObservable<Milliseconds>;
3
- export default _default;
@@ -1,3 +0,0 @@
1
- import { IObservable } from '@vkontakte/videoplayer-shared';
2
- declare const _default: (video: HTMLVideoElement) => IObservable<number>;
3
- export default _default;