capacitor-youtube-player
Advanced tools
Comparing version
@@ -1,2 +0,2 @@ | ||
import { IPlayerVars } from './web/models/models'; | ||
import { IPlayerVars, IPlayerState } from './web/models/models'; | ||
declare global { | ||
@@ -78,2 +78,77 @@ interface PluginRegistry { | ||
}>; | ||
/***********/ | ||
/***********/ | ||
mute(playerId: string): Promise<{ | ||
result: { | ||
method: string; | ||
value: boolean; | ||
}; | ||
}>; | ||
unMute(playerId: string): Promise<{ | ||
result: { | ||
method: string; | ||
value: boolean; | ||
}; | ||
}>; | ||
isMuted(playerId: string): Promise<{ | ||
result: { | ||
method: string; | ||
value: boolean; | ||
}; | ||
}>; | ||
setVolume(playerId: string, volume: Number): Promise<{ | ||
result: { | ||
method: string; | ||
value: number; | ||
}; | ||
}>; | ||
getVolume(playerId: string): Promise<{ | ||
result: { | ||
method: string; | ||
value: number; | ||
}; | ||
}>; | ||
/***********/ | ||
/***********/ | ||
setSize(playerId: string, width: Number, height: Number): Promise<{ | ||
result: { | ||
method: string; | ||
value: { | ||
width: number; | ||
height: number; | ||
}; | ||
}; | ||
}>; | ||
/***********/ | ||
/***********/ | ||
getVideoLoadedFraction(playerId: string): Promise<{ | ||
result: { | ||
method: string; | ||
value: number; | ||
}; | ||
}>; | ||
getPlayerState(playerId: string): Promise<{ | ||
result: { | ||
method: string; | ||
value: number; | ||
}; | ||
}>; | ||
getAllPlayersEventsState(): Promise<{ | ||
result: { | ||
method: string; | ||
value: Map<string, IPlayerState>; | ||
}; | ||
}>; | ||
getCurrentTime(playerId: string): Promise<{ | ||
result: { | ||
method: string; | ||
value: number; | ||
}; | ||
}>; | ||
toggleFullScreen(playerId: string, isFullScreen: boolean | null | undefined): Promise<{ | ||
result: { | ||
method: string; | ||
value: boolean | null | undefined; | ||
}; | ||
}>; | ||
} |
@@ -8,3 +8,3 @@ import { WebPlugin } from '@capacitor/core'; | ||
players: any; | ||
playersState: Map<string, IPlayerState>; | ||
playersEventsState: Map<string, IPlayerState>; | ||
player: any; | ||
@@ -160,3 +160,3 @@ playerApiLoaded: Boolean; | ||
}>; | ||
getAllPlayersState(): Promise<{ | ||
getAllPlayersEventsState(): Promise<{ | ||
result: { | ||
@@ -163,0 +163,0 @@ method: string; |
@@ -26,3 +26,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
this.players = []; | ||
this.playersState = new Map(); | ||
this.playersEventsState = new Map(); | ||
this.playerApiLoaded = false; | ||
@@ -34,3 +34,2 @@ this.defaultSizes = { | ||
} | ||
; | ||
loadPlayerApi() { | ||
@@ -86,44 +85,39 @@ return __awaiter(this, void 0, void 0, function* () { | ||
'onReady': () => { | ||
console.log(`[Youtube Player Plugin Web]: player ${options.playerId} -> onPlayerReady`); | ||
console.log(`[Youtube Player Plugin Web]: player "${options.playerId}" -> onPlayerReady`); | ||
const state = { events: { onReady: { text: 'onReady', value: true } } }; | ||
this.playersState.set(options.playerId, state); | ||
this.playersEventsState.set(options.playerId, state); | ||
return resolve({ playerReady: true, player: this.players[options.playerId] }); | ||
}, | ||
'onStateChange': (event) => { | ||
console.log(`[Youtube Player Plugin Web]: player ${options.playerId} -> onPlayerStateChange`); | ||
Math.PI > 4 ? "Sip" : "Nop"; | ||
let state = this.playersState.get(options.playerId) ? this.playersState.get(options.playerId) : null; | ||
console.log(`[Youtube Player Plugin Web]: player "${options.playerId}" -> onPlayerStateChange`); | ||
switch (event.data) { | ||
case PlayerState().PLAYING: | ||
console.log(`[Youtube Player Plugin Web]: player ${options.playerId} -> playing`); | ||
state.events.onStateChange = { text: 'playing', value: PlayerState().PLAYING }; | ||
console.log(`[Youtube Player Plugin Web]: player "${options.playerId}" -> playing`); | ||
this.playersEventsState.get(options.playerId).events.onStateChange = { text: 'playing', value: PlayerState().PLAYING }; | ||
break; | ||
case PlayerState().PAUSED: | ||
console.log(`[Youtube Player Plugin Web]: player ${options.playerId} -> paused`); | ||
state.events.onStateChange = { text: 'paused', value: PlayerState().PAUSED }; | ||
console.log(`[Youtube Player Plugin Web]: player "${options.playerId}" -> paused`); | ||
this.playersEventsState.get(options.playerId).events.onStateChange = { text: 'paused', value: PlayerState().PAUSED }; | ||
break; | ||
case PlayerState().ENDED: | ||
console.log(`[Youtube Player Plugin Web]: player ${options.playerId} -> ended`); | ||
state.events.onStateChange = { text: 'ended', value: PlayerState().ENDED }; | ||
console.log(`[Youtube Player Plugin Web]: player "${options.playerId}" -> ended`); | ||
this.playersEventsState.get(options.playerId).events.onStateChange = { text: 'ended', value: PlayerState().ENDED }; | ||
break; | ||
case PlayerState().BUFFERING: | ||
console.log(`[Youtube Player Plugin Web]: player ${options.playerId} -> buffering`); | ||
state.events.onStateChange = { text: 'buffering', value: PlayerState().BUFFERING }; | ||
console.log(`[Youtube Player Plugin Web]: player "${options.playerId}" -> buffering`); | ||
this.playersEventsState.get(options.playerId).events.onStateChange = { text: 'buffering', value: PlayerState().BUFFERING }; | ||
break; | ||
case PlayerState().CUED: | ||
console.log(`[Youtube Player Plugin Web]: player ${options.playerId} -> cued`); | ||
state.events.onStateChange = { text: 'cued', value: PlayerState().CUED }; | ||
console.log(`[Youtube Player Plugin Web]: player "${options.playerId}" -> cued`); | ||
this.playersEventsState.get(options.playerId).events.onStateChange = { text: 'cued', value: PlayerState().CUED }; | ||
break; | ||
} | ||
this.playersState.set(options.playerId, state); | ||
}, | ||
'onPlaybackQualityChange': (event) => { | ||
console.log(`[Youtube Player Plugin Web]: player ${options.playerId} -> onPlayerPlaybackQualityChange quality ${event.data}`); | ||
let state = this.playersState.get(options.playerId) ? this.playersState.get(options.playerId) : null; | ||
state.events.onPlaybackQualityChange = { text: 'onPlaybackQualityChange', value: event.data }; | ||
console.log(`[Youtube Player Plugin Web]: player "${options.playerId}" -> onPlayerPlaybackQualityChange quality ${event.data}`); | ||
this.playersEventsState.get(options.playerId).events.onPlaybackQualityChange = { text: 'onPlaybackQualityChange', value: event.data }; | ||
}, | ||
'onError': (error) => { | ||
console.log(`[Youtube Player Plugin Web]: player ${options.playerId} -> onPlayerError ${error}`); | ||
let state = this.playersState.get(options.playerId) ? this.playersState.get(options.playerId) : null; | ||
state.events.onError = { text: 'onError', value: error }; | ||
console.log(`[Youtube Player Plugin Web]: player "${options.playerId}" -> onPlayerError ${error}`); | ||
this.playersEventsState.get(options.playerId).events.onError = { text: 'onError', value: error }; | ||
} | ||
@@ -133,3 +127,3 @@ } })); | ||
// console.log('player', this.players[options.playerId]); | ||
console.log('playersState', this.playersState); | ||
console.log('playersEventsState', this.playersEventsState); | ||
}); | ||
@@ -154,3 +148,3 @@ }); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
console.log(`[Youtube Player Plugin Web]: player ${playerId} -> destroy`); | ||
console.log(`[Youtube Player Plugin Web]: player "${playerId}" -> destroy`); | ||
this.players[playerId].destroy(); | ||
@@ -167,3 +161,3 @@ return Promise.resolve({ result: { method: 'destroy', value: true } }); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
console.log(`[Youtube Player Plugin Web]: player ${playerId} -> stopVideo`); | ||
console.log(`[Youtube Player Plugin Web]: player "${playerId}" -> stopVideo`); | ||
this.players[playerId].stopVideo(); | ||
@@ -176,3 +170,3 @@ return Promise.resolve({ result: { method: 'stopVideo', value: true } }); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
console.log(`[Youtube Player Plugin Web]: player ${playerId} -> playVideo`); | ||
console.log(`[Youtube Player Plugin Web]: player "${playerId}" -> playVideo`); | ||
this.players[playerId].playVideo(); | ||
@@ -186,3 +180,3 @@ return Promise.resolve({ result: { method: 'playVideo', value: true } }); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
console.log(`[Youtube Player Plugin Web]: player ${playerId} -> pauseVideo`); | ||
console.log(`[Youtube Player Plugin Web]: player "${playerId}" -> pauseVideo`); | ||
this.players[playerId].pauseVideo(); | ||
@@ -196,3 +190,3 @@ return Promise.resolve({ result: { method: 'pauseVideo', value: true } }); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
console.log(`[Youtube Player Plugin Web]: player ${playerId} -> seekTo ${seconds} seconds`); | ||
console.log(`[Youtube Player Plugin Web]: player "${playerId}" -> seekTo ${seconds} seconds`); | ||
this.players[playerId].seekTo(seconds, allowSeekAhead); | ||
@@ -205,3 +199,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}`); | ||
console.log(`[Youtube Player Plugin Web]: player "${playerId}" -> loadVideoById with options ${options}`); | ||
this.players[playerId].loadVideoById(options); | ||
@@ -214,3 +208,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}`); | ||
console.log(`[Youtube Player Plugin Web]: player "${playerId}" -> cueVideoById with options ${options}`); | ||
this.players[playerId].cueVideoById(options); | ||
@@ -226,3 +220,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`); | ||
console.log(`[Youtube Player Plugin Web]: player "${playerId}" -> mute`); | ||
this.players[playerId].mute(); | ||
@@ -235,3 +229,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`); | ||
console.log(`[Youtube Player Plugin Web]: player "${playerId}" -> unMute`); | ||
this.players[playerId].unMute(); | ||
@@ -244,3 +238,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`); | ||
console.log(`[Youtube Player Plugin Web]: player "${playerId}" -> isMuted`); | ||
return Promise.resolve({ result: { method: 'isMuted', value: this.players[playerId].isMuted() } }); | ||
@@ -252,3 +246,3 @@ }); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
console.log(`[Youtube Player Plugin Web]: player ${playerId} -> setVolume ${volume}`); | ||
console.log(`[Youtube Player Plugin Web]: player "${playerId}" -> setVolume ${volume}`); | ||
this.players[playerId].setVolume(volume); | ||
@@ -261,3 +255,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`); | ||
console.log(`[Youtube Player Plugin Web]: player "${playerId}" -> getVolume`); | ||
return Promise.resolve({ result: { method: 'getVolume', value: this.players[playerId].getVolume() } }); | ||
@@ -272,3 +266,3 @@ }); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
console.log(`[Youtube Player Plugin Web]: player ${playerId} -> setSize width: ${width} height: ${height}`); | ||
console.log(`[Youtube Player Plugin Web]: player "${playerId}" -> setSize width: ${width} height: ${height}`); | ||
this.players[playerId].setSize(width, height); | ||
@@ -285,3 +279,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`); | ||
console.log(`[Youtube Player Plugin Web]: player "${playerId}" -> getVideoLoadedFraction`); | ||
return Promise.resolve({ result: { method: 'getVideoLoadedFraction', value: this.players[playerId].getVideoLoadedFraction() } }); | ||
@@ -299,10 +293,10 @@ }); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
console.log(`[Youtube Player Plugin Web]: player ${playerId} -> getPlayerState`); | ||
console.log(`[Youtube Player Plugin Web]: player "${playerId}" -> getPlayerState`); | ||
return Promise.resolve({ result: { method: 'getPlayerState', value: this.players[playerId].getPlayerState() } }); | ||
}); | ||
} | ||
getAllPlayersState() { | ||
getAllPlayersEventsState() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
console.log(`[Youtube Player Plugin Web]: getAllPlayersState`); | ||
return Promise.resolve({ result: { method: 'getAllPlayersState', value: this.playersState } }); | ||
console.log(`[Youtube Player Plugin Web]: getAllPlayersEventsState`); | ||
return Promise.resolve({ result: { method: 'getAllPlayersEventsState', value: this.playersEventsState } }); | ||
}); | ||
@@ -313,3 +307,3 @@ } | ||
return __awaiter(this, void 0, void 0, function* () { | ||
console.log(`[Youtube Player Plugin Web]: player ${playerId} -> getCurrentTime`); | ||
console.log(`[Youtube Player Plugin Web]: player "${playerId}" -> getCurrentTime`); | ||
return Promise.resolve({ result: { method: 'getCurrentTime', value: this.players[playerId].getCurrentTime() } }); | ||
@@ -320,3 +314,3 @@ }); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
console.log(`[Youtube Player Plugin Web]: player ${playerId} -> toggleFullScreen`); | ||
console.log(`[Youtube Player Plugin Web]: player "${playerId}" -> toggleFullScreen`); | ||
let { height, width } = this.defaultSizes; | ||
@@ -323,0 +317,0 @@ if (!isFullScreen) { |
{ | ||
"name": "capacitor-youtube-player", | ||
"version": "1.0.0-alpha.1-28", | ||
"version": "1.0.0-alpha.1-29", | ||
"description": "Youtube Player", | ||
@@ -5,0 +5,0 @@ "main": "dist/esm/index.js", |
Sorry, the diff of this file is not supported yet
1444098
0.1%939
7.93%