@tivio/sdk-js 2.0.0-alpha3 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -12,14 +12,28 @@ yarn add @tivio/sdk-js
12
12
 
13
13
  # Changelog
14
14
 
15
- * 2.0.0-alpha2
16
- * add fetch polyfill
17
- * requires core-js at least 1.12.0
18
- * force using cloud fn instead of resolver
19
- * major: rename positionMs to startFromPosition
20
- * minor: add streamStart to TvProgramSource
21
- * minor: add continueFromPosition to TvProgramSource, TivioVodSource, OtherSource and LiveTvChannelSource
22
- * minor: live_tv_channel source type does pass-through instead of stopping the setSource action
15
+ * 2.2.0
16
+ * minor: add `getProgramTimestamps`
17
+ * minor: add `addEventListener('markers', ...)` to player wrapper
18
+ * minor: add optional `calibrationId` parameter to `setSource`
19
+ * 2.1.0
20
+ * minor: better es5 polyfills
21
+ * patch: add `verbose` to Tivio config type
22
+ * patch: add `bundleUrlOverride` to Tivio config type
23
+ * patch: fix of registering player wrapper when `createPlayerWrapper` is called after tivio init
24
+ * 2.0.0
25
+ * requires core-js at least 1.13.0
26
+ * major: remove `createPlayerWrapper` from Tivio API object
27
+ * major: rename `positionMs` to `startFromPosition`
28
+ * minor: add `createPlayerWrapper` to the root of the @tivio-sdk-js package, it's not necessary to wait until
29
+ `createTivio` is finished before using it but it is still necessary to call `createTivio` at some point
30
+ * minor: add (optional) `capabilitiesOptions` and `deviceCapabilities` options to Tivio config
31
+ * minor: add fetch polyfill
32
+ * minor: better source types documentation
33
+ * minor: add `streamStart` to `TvProgramSource`
34
+ * minor: add `continueFromPosition` to `TvProgramSource`, `TivioVodSource`, `OtherSource` and `LiveTvChannelSource`
35
+ * minor: `live_tv_channel` source type does pass-through instead of stopping the `setSource` action
36
+ * minor: add `forceCloudFnResolver` option to Tivio config
23
37
  * 1.1.0
24
38
  * minor: fallback to fetch bundle by cloud fn when indexedDB not supported
25
39
  * minor: transpile to es5
@@ -134,17 +134,38 @@ declare type AdMetadata = {
134
134
  totalCount: number | null;
135
135
  skip: () => void;
136
136
  } | null;
137
+ interface Marker {
138
+ id: string;
139
+ from: Date;
140
+ to: Date;
141
+ relativeFromMs: number;
142
+ relativeToMs: number;
143
+ type: 'AD' | 'AD_SEGMENT' | 'START' | 'END' | 'INTRO';
144
+ }
137
145
  declare enum PlayerWrapperEventType {
138
- adMetadata = "adMetadata"
146
+ adMetadata = "adMetadata",
147
+ markers = "markers"
139
148
  }
140
- declare type TivioPlayerWrapper = {
141
- addEventListener: (eventType: PlayerWrapperEventType.adMetadata, listener: (metadata: AdMetadata) => void) => void;
149
+ declare type PlayerWrapperEventTypeType = `${PlayerWrapperEventType}`;
150
+ declare type ListenerAdMetadata = (metadata: AdMetadata) => void;
151
+ declare type ListenerMarkers = (marker: Marker[] | null) => void;
152
+ declare type Listener = ListenerAdMetadata | ListenerMarkers;
153
+ interface TivioPlayerWrapper {
154
+ addEventListener: (eventType: PlayerWrapperEventTypeType, listener: Listener) => void;
142
155
  reportError: (error: Error) => void;
143
156
  reportPlaybackEnded: () => void;
144
157
  reportTimeProgress: (ms: number) => void;
145
158
  seekTo: (ms: number) => void;
146
159
  setSource: (source: Source | null) => void;
147
- };
160
+ }
161
+ interface PlayerInterfaceForPlayerWrapper {
162
+ /**
163
+ * @param {number} ms - milliseconds relative to start of video (relative to 0 ms)
164
+ * or in case of TV programs relative to start of the program (relative to source.from ms)
165
+ */
166
+ seekTo: (ms: number) => void;
167
+ setSource: (source: Source | null) => void;
168
+ }
148
169
  declare type ExposedApi = {
149
170
  AdSource: any;
150
171
  ChannelSource: any;
@@ -269,9 +290,10 @@ declare type ExposedApi = {
269
290
  * @param password
270
291
  */
271
292
  signInWithEmailAndPassword: (email: string, password: string) => Promise<void>;
272
- createPlayerWrapper: (playerImplementation: {
273
- setSource: (source: Source | null) => void;
274
- seekTo: (ms: number) => void;
275
- }) => TivioPlayerWrapper;
293
+ createPlayerWrapper: (playerImplementation: PlayerInterfaceForPlayerWrapper) => TivioPlayerWrapper;
294
+ getProgramTimestamps: (channelName: string, epgFrom: Date, epgTo: Date) => Promise<{
295
+ startTimestamp?: number;
296
+ endTimestamp?: number;
297
+ } | null>;
276
298
  };
277
- export { AdMetadata, AdSource, ExposedApi, LiveTvChannelSource, OtherSource, PlayerWrapperEventType, Source, TivioPlayerWrapper, TivioVodSource, TvProgramSource, };
299
+ export type { AdMetadata, AdSource, ExposedApi, LiveTvChannelSource, OtherSource, PlayerInterfaceForPlayerWrapper, PlayerWrapperEventType, PlayerWrapperEventTypeType, Source, TivioPlayerWrapper, TivioVodSource, TvProgramSource, Marker, ListenerAdMetadata, ListenerMarkers, Listener, };
package/dist/conf.d.ts CHANGED
@@ -5,7 +5,32 @@
5
5
  import { Logger } from './services/logger';
6
6
  import { FetchPackage } from './services/packageLoader';
7
7
  import { Conf as ExternalConf } from './types';
8
+ export interface PlayerCapability {
9
+ codec: 'h264' | 'h265';
10
+ encryption: 'fairplay' | 'none' | 'playready' | 'widevine';
11
+ protocol: 'dash' | 'hls';
12
+ }
8
13
  export declare type InternalConf = {
14
+ /**
15
+ * @private URL of remote code bundle to be fetched directly (without using resolver)
16
+ */
17
+ bundleUrlOverride?: string;
18
+ /**
19
+ * Tells Tivio which technologies/protocols etc. is the device capable to play.
20
+ * If not provided, Tivio will try to guess it (based on the browser).
21
+ */
22
+ deviceCapabilities?: PlayerCapability[];
23
+ /**
24
+ * Additional options for deviceCapabilities
25
+ */
26
+ capabilitiesOptions?: {
27
+ /**
28
+ * Should the player prefer HTTP sources instead HTTPs if they are available.
29
+ * This can be used on platforms that support mixed content but do not support
30
+ * specific HTTPS certificates. (e.g. certificates from Letsencrypt not supported on LG TVs)
31
+ */
32
+ preferHttp?: boolean;
33
+ };
9
34
  secret: string;
10
35
  resolverUrl: string;
11
36
  logger?: Logger | null;
@@ -13,9 +38,19 @@ export declare type InternalConf = {
13
38
  language?: string;
14
39
  sdkVersion: string;
15
40
  /**
16
- * Defaults to true
41
+ * Can force using bundle resolver method which doesn't depend on indexedDB (useful when some polyfill
42
+ * for indexedDB is used but indexedDB is not fully supported - it leads to situation where check for indexedDB
43
+ * presence passes but resolver fails anyway).
44
+ */
45
+ forceCloudFnResolver?: boolean;
46
+ /**
47
+ * Can turn off Tivio's Sentry logging, defaults to true.
17
48
  */
18
49
  enableSentry?: boolean;
50
+ /**
51
+ * Can turn on Tivio's console logging, defaults to false.
52
+ */
53
+ verbose?: boolean;
19
54
  };
20
55
  export declare const defaultConf: {
21
56
  resolverUrl: string;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,7 @@
1
1
  import 'whatwg-fetch';
2
+ import 'core-js/actual';
2
3
  export * from './services/bundleLoader';
4
+ export * from './services/getProgramTimestamps';
3
5
  export * from './types';
4
6
  export * from './api.types';
7
+ export { createPlayerWrapper } from './services/playerWrapper';