🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →

capacitor-youtube-player

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

capacitor-youtube-player - npm Package Compare versions

Comparing version

to
1.0.0-alpha.1-25

import { WebPlugin } from '@capacitor/core';
import { IPlayerSize, IPlayerVars } from './web/models/models';
import { IPlayerSize, IPlayerVars, IPlayerState } from './web/models/models';
export declare function YT(): any;

@@ -8,2 +8,3 @@ export declare function Player(): any;

players: any;
playersState: IPlayerState;
player: any;

@@ -159,2 +160,8 @@ playerApiLoaded: Boolean;

}>;
getAllPlayersState(): Promise<{
result: {
method: string;
value: IPlayerState;
};
}>;
getCurrentTime(playerId: string): Promise<{

@@ -161,0 +168,0 @@ result: {

@@ -26,2 +26,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

this.players = [];
this.playersState = {
events: {
onReady: {},
onStateChange: {},
onPlaybackQualityChange: {},
onError: {}
}
};
this.playerApiLoaded = false;

@@ -74,5 +82,5 @@ this.defaultSizes = {

console.log('[Youtube Player Plugin Web]: createPlayer');
console.log('options', options);
// console.log('options', options);
const playerSize = this.checkSize(options);
console.log('playerSize', playerSize);
// console.log('playerSize', playerSize);
return yield new Promise(resolve => {

@@ -84,22 +92,23 @@ console.log(YT());

'onReady': () => {
console.log('[Youtube Player Plugin Web]: onPlayerReady');
console.log(`[Youtube Player Plugin Web]: player ${options.playerId} -> onPlayerReady`);
this.playersState[options.playerId].events.onReady = { text: 'onReady', value: true };
return resolve({ playerReady: true, player: this.players[options.playerId] });
},
'onStateChange': (event) => {
console.log('[Youtube Player Plugin Web]: onPlayerStateChange', event.data);
console.log(`[Youtube Player Plugin Web]: player ${options.playerId} -> onPlayerStateChange`);
switch (event.data) {
case PlayerState().PLAYING:
console.log('[Youtube Player Plugin Web]: playing');
console.log(`[Youtube Player Plugin Web]: player ${options.playerId} -> playing`);
break;
case PlayerState().PAUSED:
console.log('[Youtube Player Plugin Web]: paused');
console.log(`[Youtube Player Plugin Web]: player ${options.playerId} -> paused`);
break;
case PlayerState().ENDED:
console.log('[Youtube Player Plugin Web]: ended');
console.log(`[Youtube Player Plugin Web]: player ${options.playerId} -> ended`);
break;
case PlayerState().BUFFERING:
console.log('[Youtube Player Plugin Web]: buffering');
console.log(`[Youtube Player Plugin Web]: player ${options.playerId} -> buffering`);
break;
case PlayerState().CUED:
console.log('[Youtube Player Plugin Web]: cued');
console.log(`[Youtube Player Plugin Web]: player ${options.playerId} -> cued`);
break;

@@ -109,10 +118,11 @@ }

'onPlaybackQualityChange': () => {
console.log('[Youtube Player Plugin Web]: onPlayerPlaybackQualityChange');
console.log(`[Youtube Player Plugin Web]: player ${options.playerId} -> onPlayerPlaybackQualityChange`);
},
'onError': () => {
console.log('[Youtube Player Plugin Web]: onPlayerError');
console.log(`[Youtube Player Plugin Web]: player ${options.playerId} -> onPlayerError`);
}
} }));
console.log('players', this.players);
console.log('player', this.players[options.playerId]);
// console.log('players', this.players);
// console.log('player', this.players[options.playerId]);
console.log('playersState', this.playersState);
});

@@ -137,3 +147,3 @@ });

return __awaiter(this, void 0, void 0, function* () {
console.log('[Youtube Player Plugin Web]: destroy');
console.log(`[Youtube Player Plugin Web]: player ${playerId} -> destroy`);
this.players[playerId].destroy();

@@ -150,3 +160,3 @@ return Promise.resolve({ result: { method: 'destroy', value: true } });

return __awaiter(this, void 0, void 0, function* () {
console.log('[Youtube Player Plugin Web]: stopVideo');
console.log(`[Youtube Player Plugin Web]: player ${playerId} -> stopVideo`);
this.players[playerId].stopVideo();

@@ -159,3 +169,3 @@ return Promise.resolve({ result: { method: 'stopVideo', value: true } });

return __awaiter(this, void 0, void 0, function* () {
console.log('[Youtube Player Plugin Web]: playVideo');
console.log(`[Youtube Player Plugin Web]: player ${playerId} -> playVideo`);
this.players[playerId].playVideo();

@@ -169,3 +179,3 @@ return Promise.resolve({ result: { method: 'playVideo', value: true } });

return __awaiter(this, void 0, void 0, function* () {
console.log('[Youtube Player Plugin Web]: pauseVideo');
console.log(`[Youtube Player Plugin Web]: player ${playerId} -> pauseVideo`);
this.players[playerId].pauseVideo();

@@ -179,3 +189,3 @@ return Promise.resolve({ result: { method: 'pauseVideo', value: true } });

return __awaiter(this, void 0, void 0, function* () {
console.log('[Youtube Player Plugin Web]: seekTo');
console.log(`[Youtube Player Plugin Web]: player ${playerId} -> seekTo ${seconds} seconds`);
this.players[playerId].seekTo(seconds, allowSeekAhead);

@@ -188,2 +198,3 @@ return Promise.resolve({ result: { method: 'seekTo', value: true, seconds: seconds, allowSeekAhead: allowSeekAhead } });

return __awaiter(this, void 0, void 0, function* () {
console.log(`[Youtube Player Plugin Web]: player ${playerId} -> loadVideoById with options ${options}`);
this.players[playerId].loadVideoById(options);

@@ -196,2 +207,3 @@ return Promise.resolve({ result: { method: 'loadVideoById', value: true, options: options } });

return __awaiter(this, void 0, void 0, function* () {
console.log(`[Youtube Player Plugin Web]: player ${playerId} -> cueVideoById with options ${options}`);
this.players[playerId].cueVideoById(options);

@@ -207,2 +219,3 @@ return Promise.resolve({ result: { method: 'cueVideoById', value: true, options: options } });

return __awaiter(this, void 0, void 0, function* () {
console.log(`[Youtube Player Plugin Web]: player ${playerId} -> mute`);
this.players[playerId].mute();

@@ -215,2 +228,3 @@ return Promise.resolve({ result: { method: 'mute', value: true } });

return __awaiter(this, void 0, void 0, function* () {
console.log(`[Youtube Player Plugin Web]: player ${playerId} -> unMute`);
this.players[playerId].unMute();

@@ -223,2 +237,3 @@ return Promise.resolve({ result: { method: 'unMute', value: true } });

return __awaiter(this, void 0, void 0, function* () {
console.log(`[Youtube Player Plugin Web]: player ${playerId} -> isMuted`);
return Promise.resolve({ result: { method: 'isMuted', value: this.players[playerId].isMuted() } });

@@ -230,2 +245,3 @@ });

return __awaiter(this, void 0, void 0, function* () {
console.log(`[Youtube Player Plugin Web]: player ${playerId} -> setVolume ${volume}`);
this.players[playerId].setVolume(volume);

@@ -238,2 +254,3 @@ return Promise.resolve({ result: { method: 'setVolume', value: volume } });

return __awaiter(this, void 0, void 0, function* () {
console.log(`[Youtube Player Plugin Web]: player ${playerId} -> getVolume`);
return Promise.resolve({ result: { method: 'getVolume', value: this.players[playerId].getVolume() } });

@@ -248,2 +265,3 @@ });

return __awaiter(this, void 0, void 0, function* () {
console.log(`[Youtube Player Plugin Web]: player ${playerId} -> setSize width: ${width} height: ${height}`);
this.players[playerId].setSize(width, height);

@@ -260,2 +278,3 @@ return Promise.resolve({ result: { method: 'setSize', value: { width: width, height: height } } });

return __awaiter(this, void 0, void 0, function* () {
console.log(`[Youtube Player Plugin Web]: player ${playerId} -> getVideoLoadedFraction`);
return Promise.resolve({ result: { method: 'getVideoLoadedFraction', value: this.players[playerId].getVideoLoadedFraction() } });

@@ -273,8 +292,16 @@ });

return __awaiter(this, void 0, void 0, function* () {
console.log(`[Youtube Player Plugin Web]: player ${playerId} -> getPlayerState`);
return Promise.resolve({ result: { method: 'getPlayerState', value: this.players[playerId].getPlayerState() } });
});
}
getAllPlayersState() {
return __awaiter(this, void 0, void 0, function* () {
console.log(`[Youtube Player Plugin Web]: getAllPlayersState`);
return Promise.resolve({ result: { method: 'getAllPlayersState', value: this.playersState } });
});
}
// Returns the elapsed time in seconds since the video started playing.
getCurrentTime(playerId) {
return __awaiter(this, void 0, void 0, function* () {
console.log(`[Youtube Player Plugin Web]: player ${playerId} -> getCurrentTime`);
return Promise.resolve({ result: { method: 'getCurrentTime', value: this.players[playerId].getCurrentTime() } });

@@ -285,2 +312,3 @@ });

return __awaiter(this, void 0, void 0, function* () {
console.log(`[Youtube Player Plugin Web]: player ${playerId} -> toggleFullScreen`);
let { height, width } = this.defaultSizes;

@@ -287,0 +315,0 @@ if (!isFullScreen) {

@@ -27,1 +27,10 @@ export interface IPlayerSize {

}
export interface IPlayerState {
[key: string]: any;
events: {
onReady: Object;
onStateChange: Object;
onPlaybackQualityChange: Object;
onError: Object;
};
}
{
"name": "capacitor-youtube-player",
"version": "1.0.0-alpha.1-24",
"version": "1.0.0-alpha.1-25",
"description": "Youtube Player",

@@ -5,0 +5,0 @@ "main": "dist/esm/index.js",

@@ -71,3 +71,3 @@ ![Built With Capacitor](https://img.shields.io/badge/-Built%20With%20Capacitor-16161d.svg?logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDE5LjIuMSwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPgo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9IkxheWVyXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IgoJIHZpZXdCb3g9IjAgMCA1MTIgNTEyIiBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCA1MTIgNTEyOyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI%2BCjxzdHlsZSB0eXBlPSJ0ZXh0L2NzcyI%2BCgkuc3Qwe2ZpbGw6I0ZGRkZGRjt9Cjwvc3R5bGU%2BCjxwYXRoIGNsYXNzPSJzdDAiIGQ9Ik00MjQuNywzNzMuOWMwLDM3LjYtNTUuMSw2OC42LTkyLjcsNjguNkgxODAuNGMtMzcuOSwwLTkyLjctMzAuNy05Mi43LTY4LjZ2LTMuNmgzMzYuOVYzNzMuOXoiLz4KPHBhdGggY2xhc3M9InN0MCIgZD0iTTQyNC43LDI5Mi4xSDE4MC40Yy0zNy42LDAtOTIuNy0zMS05Mi43LTY4LjZ2LTMuNkgzMzJjMzcuNiwwLDkyLjcsMzEsOTIuNyw2OC42VjI5Mi4xeiIvPgo8cGF0aCBjbGFzcz0ic3QwIiBkPSJNNDI0LjcsMTQxLjdIODcuN3YtMy42YzAtMzcuNiw1NC44LTY4LjYsOTIuNy02OC42SDMzMmMzNy45LDAsOTIuNywzMC43LDkyLjcsNjguNlYxNDEuN3oiLz4KPC9zdmc%2BCg%3D%3D&colorA=16161d&style=flat-square)

IMPORTANT NOTE iOS:
### IMPORTANT NOTE iOS:

@@ -78,3 +78,35 @@ Currently there is a small error when you testing the plugin in iOS. The following line of code needs to be modified in xcode:

### IMPORTANT NOTE ANDROID
You have to register Youtube Player plugin's class in your Acitivity so Capacitor is aware of it.
```bash
package com.example.app;
import android.os.Bundle;
import com.abpjap.plugin.youtubeplayer.YoutubePlayer;
import com.getcapacitor.BridgeActivity;
import com.getcapacitor.Plugin;
import java.util.ArrayList;
public class MainActivity extends BridgeActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Initializes the Bridge
this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{
// Additional plugins you've installed go here
// Ex: add(TotallyAwesomePlugin.class);
add(YoutubePlayer.class); <= ADD THIS LINE
}});
}
}
```
In the official [Capacitor documentation](https://capacitor.ionicframework.com/docs/plugins/android#export-to-capacitor) appears how to register the plugin.
### Ionic / Angular project

@@ -81,0 +113,0 @@

Sorry, the diff of this file is not supported yet