From 10b3ff3b9a3e68340a1ed8bcd84a50c7d633b779 Mon Sep 17 00:00:00 2001 From: olivierapivideo Date: Wed, 7 Jul 2021 18:01:26 +0200 Subject: [PATCH] Add showSubtitles() / hideSubtitles() methods --- CHANGELOG.md | 3 +++ README.md | 27 ++++++++++++++++----------- dist/index.d.ts | 3 +++ dist/index.js | 2 +- index.ts | 11 +++++++++++ package-lock.json | 2 +- package.json | 2 +- 7 files changed, 36 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f3953b7..1ef7756 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Changelog All changes to this project will be documented in this file. +## [1.2.8] - 2021-05-28 +- Add showSubtitles() / hideSubtitles() methods + ## [1.2.7] - 2021-05-28 - Add "token" in SdkOptions type diff --git a/README.md b/README.md index 977f611..1bd2c87 100644 --- a/README.md +++ b/README.md @@ -73,17 +73,18 @@ The PlayerSdk constructor takes 2 parameters: - `options: SdkOptions` an object containing the player options. The available options are the following: -| Option name | Mandatory | Type | Description | -| -----------: | --------------------- | ------- | ------------------------------------------------------------------------------------------------------------ | -| id | **yes** | string | the id of the video | -| token | yes for private video | string | the [private video](https://api.video/blog/tutorials/tutorial-private-videos) url token | -| live | no (default: false) | boolean | indicate that the video is a live one | -| autoplay | no (default: false) | boolean | start playing the video as soon as it is loaded | -| muted | no (default: false) | boolean | the video is muted | -| metadata | no (default: empty) | object | object containing [metadata](https://api.video/blog/tutorials/dynamic-metadata) (see **Full example** below) | -| hideControls | no (default: false) | boolean | the controls are hidden | -| hideTitle | no (default: false) | boolean | the video title is hidden | -| loop | no (default: false) | boolean | once the video is finished it automatically starts again | +| Option name | Mandatory | Type | Description | +| ------------: | --------------------- | ------- | ------------------------------------------------------------------------------------------------------------ | +| id | **yes** | string | the id of the video | +| token | yes for private video | string | the [private video](https://api.video/blog/tutorials/tutorial-private-videos) url token | +| live | no (default: false) | boolean | indicate that the video is a live one | +| autoplay | no (default: false) | boolean | start playing the video as soon as it is loaded | +| muted | no (default: false) | boolean | the video is muted | +| metadata | no (default: empty) | object | object containing [metadata](https://api.video/blog/tutorials/dynamic-metadata) (see **Full example** below) | +| hideControls | no (default: false) | boolean | the controls are hidden | +| hideTitle | no (default: false) | boolean | the video title is hidden | +| showSubtitles | no (default: false) | boolean | the video subtitles are shown by default | +| loop | no (default: false) | boolean | once the video is finished it automatically starts again | The sdk instance can be used to control the video playback, and to listen to player events. @@ -115,6 +116,10 @@ The sdk instance has the following methods: > Hide the player controls. #### `showControls()` > Show the player controls. +#### `hideSubtitles()` +> Hide the player subtitles. +#### `showSubtitles()` +> Show the player subtitles. #### `setLoop(loop: boolean)` > Define if the video should be played in loop. #### `seek(time: number)` diff --git a/dist/index.d.ts b/dist/index.d.ts index 00ccd8f..c2c002b 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -11,6 +11,7 @@ declare type SdkOptions = { hideTitle?: boolean; iframeUrl?: string; token?: string; + showSubtitles?: boolean; }; export declare class PlayerSdk { private static DEFAULT_IFRAME_URL; @@ -29,6 +30,8 @@ export declare class PlayerSdk { play(): void; hideControls(): void; showControls(): void; + hideSubtitles(): void; + showSubtitles(): void; pause(): void; mute(): void; unmute(): void; diff --git a/dist/index.js b/dist/index.js index ccc66f7..ee4af80 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1 +1 @@ -!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n=e();for(var r in n)("object"==typeof exports?exports:t)[r]=n[r]}}(this,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=59)}([function(t,e,n){(function(e){var n=function(t){return t&&t.Math==Math&&t};t.exports=n("object"==typeof globalThis&&globalThis)||n("object"==typeof window&&window)||n("object"==typeof self&&self)||n("object"==typeof e&&e)||function(){return this}()||Function("return this")()}).call(this,n(38))},function(t,e,n){var r=n(0),o=n(41),i=n(3),a=n(42),c=n(49),s=n(78),u=o("wks"),f=r.Symbol,p=s?f:f&&f.withoutSetter||a;t.exports=function(t){return i(u,t)||(c&&i(f,t)?u[t]=f[t]:u[t]=p("Symbol."+t)),u[t]}},function(t,e){t.exports=function(t){try{return!!t()}catch(t){return!0}}},function(t,e){var n={}.hasOwnProperty;t.exports=function(t,e){return n.call(t,e)}},function(t,e,n){var r=n(6);t.exports=function(t){if(!r(t))throw TypeError(String(t)+" is not an object");return t}},function(t,e,n){var r=n(9),o=n(10),i=n(15);t.exports=r?function(t,e,n){return o.f(t,e,i(1,n))}:function(t,e,n){return t[e]=n,t}},function(t,e){t.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},function(t,e,n){var r=n(43),o=n(0),i=function(t){return"function"==typeof t?t:void 0};t.exports=function(t,e){return arguments.length<2?i(r[t])||i(o[t]):r[t]&&r[t][e]||o[t]&&o[t][e]}},function(t,e,n){var r=n(0),o=n(20).f,i=n(5),a=n(11),c=n(24),s=n(66),u=n(46);t.exports=function(t,e){var n,f,p,l,h,v=t.target,d=t.global,y=t.stat;if(n=d?r:y?r[v]||c(v,{}):(r[v]||{}).prototype)for(f in e){if(l=e[f],p=t.noTargetGet?(h=o(n,f))&&h.value:n[f],!u(d?f:v+(y?".":"#")+f,t.forced)&&void 0!==p){if(typeof l==typeof p)continue;s(l,p)}(t.sham||p&&p.sham)&&i(l,"sham",!0),a(n,f,l,t)}}},function(t,e,n){var r=n(2);t.exports=!r((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]}))},function(t,e,n){var r=n(9),o=n(40),i=n(4),a=n(39),c=Object.defineProperty;e.f=r?c:function(t,e,n){if(i(t),e=a(e,!0),i(n),o)try{return c(t,e,n)}catch(t){}if("get"in n||"set"in n)throw TypeError("Accessors not supported");return"value"in n&&(t[e]=n.value),t}},function(t,e,n){var r=n(0),o=n(5),i=n(3),a=n(24),c=n(25),s=n(17),u=s.get,f=s.enforce,p=String(String).split("String");(t.exports=function(t,e,n,c){var s,u=!!c&&!!c.unsafe,l=!!c&&!!c.enumerable,h=!!c&&!!c.noTargetGet;"function"==typeof n&&("string"!=typeof e||i(n,"name")||o(n,"name",e),(s=f(n)).source||(s.source=p.join("string"==typeof e?e:""))),t!==r?(u?!h&&t[e]&&(l=!0):delete t[e],l?t[e]=n:o(t,e,n)):l?t[e]=n:a(e,n)})(Function.prototype,"toString",(function(){return"function"==typeof this&&u(this).source||c(this)}))},function(t,e){t.exports=function(t){if("function"!=typeof t)throw TypeError(String(t)+" is not a function");return t}},function(t,e){t.exports=!1},function(t,e){t.exports={}},function(t,e){t.exports=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}}},function(t,e,n){var r=n(64),o=n(22);t.exports=function(t){return r(o(t))}},function(t,e,n){var r,o,i,a=n(65),c=n(0),s=n(6),u=n(5),f=n(3),p=n(26),l=n(27),h=n(28),v=c.WeakMap;if(a){var d=p.state||(p.state=new v),y=d.get,g=d.has,m=d.set;r=function(t,e){return e.facade=t,m.call(d,t,e),e},o=function(t){return y.call(d,t)||{}},i=function(t){return g.call(d,t)}}else{var b=l("state");h[b]=!0,r=function(t,e){return e.facade=t,u(t,b,e),e},o=function(t){return f(t,b)?t[b]:{}},i=function(t){return f(t,b)}}t.exports={set:r,get:o,has:i,enforce:function(t){return i(t)?o(t):r(t,{})},getterFor:function(t){return function(e){var n;if(!s(e)||(n=o(e)).type!==t)throw TypeError("Incompatible receiver, "+t+" required");return n}}}},function(t,e,n){var r=n(4),o=n(77),i=n(45),a=n(50),c=n(79),s=n(80),u=function(t,e){this.stopped=t,this.result=e};t.exports=function(t,e,n){var f,p,l,h,v,d,y,g=n&&n.that,m=!(!n||!n.AS_ENTRIES),b=!(!n||!n.IS_ITERATOR),x=!(!n||!n.INTERRUPTED),w=a(e,g,1+m+x),S=function(t){return f&&s(f),new u(!0,t)},P=function(t){return m?(r(t),x?w(t[0],t[1],S):w(t[0],t[1])):x?w(t,S):w(t)};if(b)f=t;else{if("function"!=typeof(p=c(t)))throw TypeError("Target is not iterable");if(o(p)){for(l=0,h=i(t.length);h>l;l++)if((v=P(t[l]))&&v instanceof u)return v;return new u(!1)}f=p.call(t)}for(d=f.next;!(y=d.call(f)).done;){try{v=P(y.value)}catch(t){throw s(f),t}if("object"==typeof v&&v&&v instanceof u)return v}return new u(!1)}},function(t,e,n){"use strict";var r=n(12),o=function(t){var e,n;this.promise=new t((function(t,r){if(void 0!==e||void 0!==n)throw TypeError("Bad Promise constructor");e=t,n=r})),this.resolve=r(e),this.reject=r(n)};t.exports.f=function(t){return new o(t)}},function(t,e,n){var r=n(9),o=n(63),i=n(15),a=n(16),c=n(39),s=n(3),u=n(40),f=Object.getOwnPropertyDescriptor;e.f=r?f:function(t,e){if(t=a(t),e=c(e,!0),u)try{return f(t,e)}catch(t){}if(s(t,e))return i(!o.f.call(t,e),t[e])}},function(t,e){var n={}.toString;t.exports=function(t){return n.call(t).slice(8,-1)}},function(t,e){t.exports=function(t){if(null==t)throw TypeError("Can't call method on "+t);return t}},function(t,e,n){var r=n(0),o=n(6),i=r.document,a=o(i)&&o(i.createElement);t.exports=function(t){return a?i.createElement(t):{}}},function(t,e,n){var r=n(0),o=n(5);t.exports=function(t,e){try{o(r,t,e)}catch(n){r[t]=e}return e}},function(t,e,n){var r=n(26),o=Function.toString;"function"!=typeof r.inspectSource&&(r.inspectSource=function(t){return o.call(t)}),t.exports=r.inspectSource},function(t,e,n){var r=n(0),o=n(24),i=r["__core-js_shared__"]||o("__core-js_shared__",{});t.exports=i},function(t,e,n){var r=n(41),o=n(42),i=r("keys");t.exports=function(t){return i[t]||(i[t]=o(t))}},function(t,e){t.exports={}},function(t,e){var n=Math.ceil,r=Math.floor;t.exports=function(t){return isNaN(t=+t)?0:(t>0?r:n)(t)}},function(t,e){t.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},function(t,e,n){var r=n(3),o=n(72),i=n(27),a=n(73),c=i("IE_PROTO"),s=Object.prototype;t.exports=a?Object.getPrototypeOf:function(t){return t=o(t),r(t,c)?t[c]:"function"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?s:null}},function(t,e,n){var r,o=n(4),i=n(75),a=n(30),c=n(28),s=n(48),u=n(23),f=n(27),p=f("IE_PROTO"),l=function(){},h=function(t){return"