@vkontakte/videoplayer-core 2.0.63 → 2.0.66

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/index.d.ts CHANGED
@@ -2,8 +2,7 @@ import { VideoFormat, IMpegSource, IDashSource, IHLSSource, IDashURLSource, IHLS
2
2
  import Player from "./player/Player";
3
3
  import { IPlayer, PlaybackState, IPlayerInfo, IPlayerEvents, IConfig, ISources, ICueSettings, ChromecastState, HttpConnectionType, IExternalTextTrack, ITextTrack } from "./player/types";
4
4
  import { VideoQuality, ExactVideoQuality } from "./utils/quality/types";
5
- import { IRange } from "./utils/range";
6
- import type { ISubscription, IUnsubscriber, IEmitter, IObservable, IValueObservable, IValue, IOperator, IListener, ILogEntry } from '@vkontakte/videoplayer-shared';
5
+ import type { ISubscription, IUnsubscriber, IEmitter, IObservable, IValueObservable, IValue, IOperator, IListener, ILogEntry, IRange } from '@vkontakte/videoplayer-shared';
7
6
  import { Subscription, Observable, Subject, ValueSubject } from '@vkontakte/videoplayer-shared';
8
7
  /**
9
8
  * Версия sdk
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vkontakte/videoplayer-core",
3
- "version": "2.0.63",
3
+ "version": "2.0.66",
4
4
  "author": "vk.com",
5
5
  "description": "Videoplayer core library based on the vk.com platform",
6
6
  "homepage": "https://vk.com",
@@ -14,7 +14,7 @@
14
14
  "**/*.d.ts"
15
15
  ],
16
16
  "dependencies": {
17
- "@vkontakte/videoplayer-shared": "^1.0.14",
17
+ "@vkontakte/videoplayer-shared": "^1.0.15",
18
18
  "dashjs": "4.4.0",
19
19
  "hls.js": "1.1.5",
20
20
  "lodash": "4.17.21"
@@ -1,13 +1,13 @@
1
1
  import { ITuningConfig } from "../../../utils/tuningConfig";
2
- import { IError, ISubject, IValueSubject, Milliseconds } from '@vkontakte/videoplayer-shared';
2
+ import { IError, IRange, ISubject, IValueSubject, Milliseconds } from '@vkontakte/videoplayer-shared';
3
3
  import type { Fetcher } from './fetcher';
4
- import { Container, Range, Representation, RepresentationKind } from './types';
4
+ import { Container, Representation, RepresentationKind } from './types';
5
5
  export interface Dependencies {
6
6
  fetcher: Fetcher;
7
7
  tuning: ITuningConfig;
8
8
  getCurrentPosition: () => Milliseconds | undefined;
9
9
  }
10
- export interface Gap extends Range<Milliseconds> {
10
+ export interface Gap extends IRange<Milliseconds> {
11
11
  representation: Representation['id'];
12
12
  }
13
13
  export declare class BufferManager {
@@ -1,7 +1,7 @@
1
1
  import { HttpConnectionType } from "../../../player/types";
2
- import { GenericContainerParser, Representation, Segment } from './types';
3
2
  import type ThroughputEstimator from "../../../utils/ThroughputEstimator";
4
- import { Byte, IValueSubject, Milliseconds } from '@vkontakte/videoplayer-shared';
3
+ import { Byte, IValueSubject, Milliseconds, IRange } from '@vkontakte/videoplayer-shared';
4
+ import { GenericContainerParser, Segment, SegmentReference } from './types';
5
5
  export declare enum RangeMethod {
6
6
  HEADER = 0,
7
7
  PARAM = 1
@@ -12,12 +12,17 @@ export interface IParams {
12
12
  }
13
13
  export declare type Priority = 'high' | 'low' | 'auto';
14
14
  export interface FetchParams {
15
- method?: RangeMethod;
15
+ range?: IRange<Byte>;
16
+ rangeMethod?: RangeMethod;
16
17
  onProgress?: (view: DataView, loaded: Byte) => void;
17
18
  signal?: AbortSignal;
18
19
  priority?: Priority;
19
20
  measureThroughput?: boolean;
20
21
  }
22
+ export declare type RepresentationFetchResult = {
23
+ segments: Segment[];
24
+ dataView: DataView;
25
+ };
21
26
  export declare class Fetcher {
22
27
  private throughputEstimator;
23
28
  private requestQuic;
@@ -29,11 +34,10 @@ export declare class Fetcher {
29
34
  constructor({ throughputEstimator, requestQuic }: IParams);
30
35
  private onHeadersReceived;
31
36
  fetchManifest: (param_0: string) => Promise<string | null | undefined>;
32
- fetchRange: (param_0: string, param_1: number, param_2: number, param_3: FetchParams) => Promise<ArrayBuffer | null | undefined>;
33
- fetchRepresentation: (param_0: Representation, param_1: GenericContainerParser<unknown>, param_2?: Priority | undefined, param_3?: number | undefined) => Promise<{
34
- segments: Segment[];
35
- dataView: DataView;
36
- } | null | undefined>;
37
+ fetch: (param_0: string, param_1: FetchParams) => Promise<ArrayBuffer | null | undefined>;
38
+ fetchRepresentation(segmentReference: SegmentReference, parser: GenericContainerParser<unknown>, priority?: Priority): Promise<RepresentationFetchResult | null>;
37
39
  destroy(): void;
40
+ private fetchByteRangeRepresentation;
41
+ private fetchTemplateRepresentation;
38
42
  }
39
43
  export declare const suppressAbort: (e: Error | unknown) => void;
@@ -1,2 +1,2 @@
1
1
  import { Manifest } from './types';
2
- export declare const parse: (text: string, url: string) => Manifest;
2
+ export declare const parse: (text: string, manifestUrl: string) => Manifest;
@@ -9,7 +9,7 @@ declare class SourceBufferTaskQueue {
9
9
  constructor(buffer: SourceBuffer);
10
10
  append(data: BufferSource, signal?: AbortSignal): Promise<boolean>;
11
11
  remove(from: Milliseconds, to: Milliseconds, signal?: AbortSignal): Promise<boolean>;
12
- abort(): Promise<boolean>;
12
+ abort(init?: BufferSource): Promise<boolean>;
13
13
  destroy(): void;
14
14
  private completeTask;
15
15
  private pull;
@@ -1,10 +1,9 @@
1
1
  import { QualityLimits } from "../utils/quality/types";
2
2
  import { ITuningConfig } from "../utils/tuningConfig";
3
- import { ILogger, ISubject, IValueSubject, Milliseconds, Seconds, IError } from '@vkontakte/videoplayer-shared';
3
+ import { ILogger, ISubject, IValueSubject, Milliseconds, Seconds, IRange, IError } from '@vkontakte/videoplayer-shared';
4
4
  import { IChromecastInitializer } from "./ChromecastProvider/ChromecastInitializer/types";
5
5
  import { HttpConnectionType, ICueSettings, SeekState } from "../player/types";
6
6
  import { IExternalTextTrack, ITextTrack, IVideoTrack, IVolumeState, PlaybackState } from "../player/types";
7
- import { IRange } from "../utils/range";
8
7
  import { IStateMachine } from "../utils/StateMachine/types";
9
8
  import ThroughputEstimator from "../utils/ThroughputEstimator";
10
9
  export interface IProvider {
@@ -1,5 +1,4 @@
1
- import { Seconds } from '@vkontakte/videoplayer-shared';
2
- import { IRange } from "../range";
1
+ import { Seconds, IRange } from '@vkontakte/videoplayer-shared';
3
2
  export interface IVideoBuffer extends IRange<Seconds> {
4
3
  i: number;
5
4
  }
@@ -1,6 +1,5 @@
1
- import { HttpConnectionType, ICueSettings } from "./types";
1
+ import { HttpConnectionType, ICueSettings, StartEnd } from "./types";
2
2
  import { QualityLimits, VideoQuality } from "../utils/quality/types";
3
- import { IRange } from "../utils/range";
4
3
  import { IOptionalTuningConfig } from "../utils/tuningConfig";
5
4
  import { IError, ILogEntry, Seconds, Subject, ValueSubject } from '@vkontakte/videoplayer-shared';
6
5
  import { ChromecastState, IConfig, IExternalTextTrack, IPlayer, ISeekRequest, ITextTrack, PlaybackState, StartStatus, VideoFormat } from './types';
@@ -29,7 +28,7 @@ export default class Player implements IPlayer {
29
28
  isAutoQualityEnabled$: ValueSubject<boolean>;
30
29
  autoQualityLimitingAvailable$: ValueSubject<boolean>;
31
30
  autoQualityLimits$: ValueSubject<QualityLimits>;
32
- currentBuffer$: ValueSubject<IRange<number> | undefined>;
31
+ currentBuffer$: ValueSubject<StartEnd<number> | undefined>;
33
32
  isBuffering$: ValueSubject<boolean>;
34
33
  isStalled$: ValueSubject<boolean>;
35
34
  isEnded$: ValueSubject<boolean>;
@@ -59,8 +58,8 @@ export default class Player implements IPlayer {
59
58
  willPause$: Subject<void>;
60
59
  willResume$: Subject<void>;
61
60
  willDestruct$: Subject<void>;
62
- watchCoverageRecord$: Subject<IRange<number>>;
63
- watchCoverageLive$: Subject<IRange<number>>;
61
+ watchCoverageRecord$: Subject<StartEnd<number>>;
62
+ watchCoverageLive$: Subject<StartEnd<number>>;
64
63
  managedError$: Subject<IError>;
65
64
  fatalError$: Subject<IError>;
66
65
  ended$: Subject<void>;
package/player/types.d.ts CHANGED
@@ -1,7 +1,9 @@
1
- import { IObservable, IValueObservable, IValueSubject, ILogEntry, Kbps, Milliseconds, Seconds, IError } from '@vkontakte/videoplayer-shared';
1
+ import { IObservable, IValueObservable, IValueSubject, ILogEntry, Kbps, Milliseconds, Seconds, IRectangle, IError } from '@vkontakte/videoplayer-shared';
2
2
  import { QualityLimits, VideoQuality } from "../utils/quality/types";
3
- import { IRange } from "../utils/range";
4
- import { IRectangle } from "../utils/rectangle";
3
+ export interface StartEnd<Unit extends number> {
4
+ start: Unit;
5
+ end: Unit;
6
+ }
5
7
  export interface IPlayer {
6
8
  info: IPlayerInfo;
7
9
  events: IPlayerEvents;
@@ -96,12 +98,12 @@ export interface IPlayerEvents {
96
98
  * Просмотрен промежуток видео.
97
99
  * Параметр содержит диапазон: начальная и конечная позиция просмотра (в секундах от начала ролика).
98
100
  */
99
- watchCoverageRecord$: IObservable<IRange<Seconds>>;
101
+ watchCoverageRecord$: IObservable<StartEnd<Seconds>>;
100
102
  /**
101
103
  * Просмотрен промежуток видео. Промежуток видео, которые были просмотрены пользователем.
102
104
  * Параметр содержит диапазон: начальный и конечный UTC tipestamp?
103
105
  */
104
- watchCoverageLive$: IObservable<IRange<Milliseconds>>;
106
+ watchCoverageLive$: IObservable<StartEnd<Milliseconds>>;
105
107
  /**
106
108
  * Ошибка в работе после которой воспроизведение было восстановлено
107
109
  */
@@ -209,7 +211,7 @@ export interface IPlayerInfo {
209
211
  *
210
212
  * default value: `undefined`
211
213
  */
212
- currentBuffer$: IValueObservable<IRange | undefined>;
214
+ currentBuffer$: IValueObservable<StartEnd<Seconds> | undefined>;
213
215
  /**
214
216
  * Статус буферизации видео. true если буфер пустой и воспроизведение прервано
215
217
  * В отличии от isStalled показывает и буферизации на старте и после перемотки
@@ -314,6 +316,7 @@ export interface ISources {
314
316
  [VideoFormat.DASH_WEBM_VK]?: IDashURLSource;
315
317
  [VideoFormat.DASH_WEBM]?: IDashURLSource;
316
318
  [VideoFormat.DASH_ONDEMAND]?: IDashURLSource;
319
+ [VideoFormat.DASH_ONDEMAND_VK]?: IDashURLSource;
317
320
  [VideoFormat.DASH_LIVE]?: IDashURLSource;
318
321
  [VideoFormat.DASH_LIVE_WEBM]?: IDashURLSource;
319
322
  [VideoFormat.HLS]?: IHLSSource;
@@ -351,6 +354,7 @@ export declare enum VideoFormat {
351
354
  DASH_WEBM = "DASH_WEBM",
352
355
  DASH_WEBM_VK = "DASH_WEBM_VK",
353
356
  DASH_ONDEMAND = "DASH_ONDEMAND",
357
+ DASH_ONDEMAND_VK = "DASH_ONDEMAND_VK",
354
358
  DASH_LIVE = "DASH_LIVE",
355
359
  DASH_LIVE_WEBM = "DASH_LIVE_WEBM",
356
360
  HLS = "HLS",
@@ -1,5 +1,4 @@
1
- import { IObservable, IValueObservable, Seconds } from '@vkontakte/videoplayer-shared';
2
- import { IRange } from "../../utils/range";
1
+ import { IObservable, IValueObservable, Seconds, IRange } from '@vkontakte/videoplayer-shared';
3
2
  import { IStateMachine } from "../../utils/StateMachine/types";
4
3
  import { PlaybackState, SeekState } from "../types";
5
4
  interface IParams {
@@ -1,4 +1,4 @@
1
- import { Byte, Kbps, Milliseconds } from '@vkontakte/videoplayer-shared';
1
+ import { Byte, Kbps, Milliseconds, IRange } from '@vkontakte/videoplayer-shared';
2
2
  export declare enum RepresentationKind {
3
3
  VIDEO = "video",
4
4
  AUDIO = "audio",
@@ -8,31 +8,52 @@ export declare enum Profile {
8
8
  WEBM_AS_IN_SPEC = "urn:mpeg:dash:profile:webm-on-demand:2012",
9
9
  WEBM_AS_IN_FFMPEG = "urn:webm:dash:profile:webm-on-demand:2012"
10
10
  }
11
- export interface Range<Unit extends number> {
12
- from: Unit;
13
- to: Unit;
14
- }
15
11
  export interface Representation {
16
12
  id: string;
17
13
  kind: RepresentationKind;
14
+ segmentReference: SegmentReference;
18
15
  profiles: Array<Profile | string>;
19
- initRange: Range<Byte>;
20
- indexRange?: Range<Byte>;
21
16
  duration?: Milliseconds;
22
17
  bitrate: Kbps;
23
18
  mime: string;
24
19
  codecs: string;
25
20
  width: number;
26
21
  height: number;
27
- url: string;
28
22
  fps?: number;
29
23
  quality?: string;
30
24
  }
31
- export interface Segment {
25
+ export declare enum SegmentReferencingType {
26
+ BYTE_RANGE = "byteRange",
27
+ TEMPLATE = "template"
28
+ }
29
+ export declare type ByteRangeSegmentReference = {
30
+ type: SegmentReferencingType.BYTE_RANGE;
31
+ url: string;
32
+ initRange: IRange<Byte>;
33
+ indexRange?: IRange<Byte>;
34
+ };
35
+ export declare type TemplateSegmentReference = {
36
+ type: SegmentReferencingType.TEMPLATE;
37
+ baseUrl: string;
38
+ initUrl: string;
39
+ segments: {
40
+ url: string;
41
+ time: IRange<Milliseconds>;
42
+ }[];
43
+ };
44
+ export declare type SegmentReference = ByteRangeSegmentReference | TemplateSegmentReference;
45
+ export interface ByteRangeSegment {
32
46
  status: SegmentStatus;
33
- time: Range<Milliseconds>;
34
- byte: Range<Byte>;
47
+ time: IRange<Milliseconds>;
48
+ byte: IRange<Byte>;
49
+ }
50
+ export interface TemplateSegment {
51
+ status: SegmentStatus;
52
+ time: IRange<Milliseconds>;
53
+ size: Byte | undefined;
54
+ url: string;
35
55
  }
56
+ export declare type Segment = ByteRangeSegment | TemplateSegment;
36
57
  export declare enum SegmentStatus {
37
58
  NONE = "none",
38
59
  DOWNLOADING = "downloading",
@@ -41,6 +62,7 @@ export declare enum SegmentStatus {
41
62
  FED = "fed"
42
63
  }
43
64
  export interface Manifest {
65
+ duration: Milliseconds | undefined;
44
66
  container: Container;
45
67
  representations: {
46
68
  [key in RepresentationKind]: Representation[];
@@ -52,7 +74,7 @@ export declare enum Container {
52
74
  }
53
75
  export interface GenericContainerParser<InitData> {
54
76
  validateData(data: DataView): boolean;
55
- getIndexRange(init: InitData): Range<Byte> | undefined;
77
+ getIndexRange(init: InitData): IRange<Byte> | undefined;
56
78
  parseInit(data: DataView): InitData;
57
79
  parseSegments(data: DataView, init: InitData): Segment[];
58
80
  parseFeedableSegmentChunk(data: DataView): DataView | null;
@@ -1,6 +1,5 @@
1
- import { Kbps } from '@vkontakte/videoplayer-shared';
1
+ import { Kbps, IRectangle } from '@vkontakte/videoplayer-shared';
2
2
  import { VideoQuality } from "../../utils/quality/types";
3
- import { IRectangle } from "../../utils/rectangle";
4
3
  export declare type ManifestUrl = {
5
4
  id: string;
6
5
  quality: VideoQuality;
@@ -1,7 +1,6 @@
1
1
  import { IMetadata, ISources, IVideoTrack, IVolumeState, VideoFormat } from "../../player/types";
2
- import { IRange } from "../../utils/range";
3
2
  import { ITuningConfig } from "../../utils/tuningConfig";
4
- import { IError, ISubject, IValueSubject, Subject, ValueSubject } from '@vkontakte/videoplayer-shared';
3
+ import { IError, ISubject, IValueSubject, Subject, ValueSubject, IRange } from '@vkontakte/videoplayer-shared';
5
4
  import { IDesiredState, IProviderDependencies } from '../types';
6
5
  import { IProviderContainer, IProviderEntry } from './types';
7
6
  interface IParams extends IProviderDependencies {
@@ -1,6 +1,5 @@
1
- import { Seconds, IObservable, IError } from '@vkontakte/videoplayer-shared';
1
+ import { Seconds, IRange, IObservable, IError } from '@vkontakte/videoplayer-shared';
2
2
  import { IVolumeState } from "../../player/types";
3
- import { IRange } from "../../utils/range";
4
3
  interface IObservableVideo {
5
4
  playing$: IObservable<undefined>;
6
5
  pause$: IObservable<undefined>;
@@ -1,8 +1,7 @@
1
1
  import { ITuningConfig } from "./tuningConfig";
2
- import { Kbps, Milliseconds } from '@vkontakte/videoplayer-shared';
2
+ import { Kbps, Milliseconds, IRectangle } from '@vkontakte/videoplayer-shared';
3
3
  import { IVideoTrack } from "../player/types";
4
4
  import { QualityLimits } from "./quality/types";
5
- import { IRectangle } from "./rectangle";
6
5
  export interface Constraints {
7
6
  container?: IRectangle;
8
7
  throughput?: Kbps;
@@ -1,4 +1,3 @@
1
- import { Seconds } from '@vkontakte/videoplayer-shared';
2
- import { IRange } from "../range";
1
+ import { Seconds, IRange } from '@vkontakte/videoplayer-shared';
3
2
  declare const _default: (timeRanges: TimeRanges, position: Seconds, gapTolerance?: number) => IRange<Seconds>;
4
3
  export default _default;
@@ -1,4 +1,3 @@
1
- import { IObservable, Milliseconds } from '@vkontakte/videoplayer-shared';
2
- import { IRectangle } from "./rectangle";
1
+ import { IObservable, Milliseconds, IRectangle } from '@vkontakte/videoplayer-shared';
3
2
  declare const observeElementSize: (element: Element, debounceTime?: Milliseconds) => IObservable<IRectangle>;
4
3
  export default observeElementSize;
@@ -1,4 +1,4 @@
1
- import { IRectangle } from '../rectangle';
1
+ import { IRectangle } from '@vkontakte/videoplayer-shared';
2
2
  import { ExactVideoQuality, VideoQuality } from './types';
3
3
  export declare const isHigher: (a: ExactVideoQuality, b: ExactVideoQuality) => boolean;
4
4
  export declare const isHigherOrEqual: (a: ExactVideoQuality, b: ExactVideoQuality) => boolean;
@@ -1,4 +0,0 @@
1
- export interface IRange<Unit extends number = number> {
2
- start: Unit;
3
- end: Unit;
4
- }
@@ -1,4 +0,0 @@
1
- export interface IRectangle {
2
- width: number;
3
- height: number;
4
- }