mirror of
https://github.com/iv-org/invidious.git
synced 2025-01-09 06:28:00 -05:00
better iframe size and use forEach on playerVars
This commit is contained in:
parent
ffb7b7446e
commit
b1a1e5230d
@ -160,11 +160,23 @@ class invidious_embed {
|
|||||||
let no_start_parameter = true;
|
let no_start_parameter = true;
|
||||||
if (typeof options.playerVars === 'object') {
|
if (typeof options.playerVars === 'object') {
|
||||||
this.option_playerVars = options.playerVars;
|
this.option_playerVars = options.playerVars;
|
||||||
for (let x in options.playerVars) {
|
Object.keys(options.playerVars).forEach(key=>{
|
||||||
if (typeof x === 'string' && typeof options.playerVars[x] === 'string') {
|
if (typeof key === 'string') {
|
||||||
search_params.append(x, options.playerVars[x]);
|
let keyValue = options.playerVars[key];
|
||||||
|
switch (typeof keyValue) {
|
||||||
|
case 'number':
|
||||||
|
keyValue = keyValue.toString();
|
||||||
|
break;
|
||||||
|
case 'string':
|
||||||
|
break;
|
||||||
|
default :
|
||||||
|
console.warn('player vars key value must be string or number');
|
||||||
}
|
}
|
||||||
|
search_params.append(key, keyValue);
|
||||||
|
} else {
|
||||||
|
console.warn('player vars key must be string');
|
||||||
}
|
}
|
||||||
|
})
|
||||||
if (options.playerVars.start !== undefined) {
|
if (options.playerVars.start !== undefined) {
|
||||||
no_start_parameter = false;
|
no_start_parameter = false;
|
||||||
}
|
}
|
||||||
@ -190,12 +202,9 @@ class invidious_embed {
|
|||||||
this.player_iframe.src = iframe_src;
|
this.player_iframe.src = iframe_src;
|
||||||
if (typeof options.width === 'number') {
|
if (typeof options.width === 'number') {
|
||||||
this.player_iframe.width = options.width;
|
this.player_iframe.width = options.width;
|
||||||
} else {
|
|
||||||
if (document.body.clientWidth < 640) {
|
|
||||||
this.player_iframe.width = document.body.clientWidth;
|
|
||||||
} else {
|
} else {
|
||||||
this.player_iframe.width = 640;
|
this.player_iframe.width = 640;
|
||||||
}
|
this.player_iframe.style.maxWidth = '100%';
|
||||||
}
|
}
|
||||||
if (typeof options.width === 'number') {
|
if (typeof options.width === 'number') {
|
||||||
this.player_iframe.width = options.width;
|
this.player_iframe.width = options.width;
|
||||||
@ -225,7 +234,8 @@ class invidious_embed {
|
|||||||
}
|
}
|
||||||
|
|
||||||
receiveMessage(message) {
|
receiveMessage(message) {
|
||||||
if (message.data.from === 'invidious_control' && message.data.widgetid === String(this.widgetid)) {
|
const onControlAndHasWidgetId = message.data.from==='invidious_control' && message.data.widgetid===this.widgetid.toString();
|
||||||
|
if (onControlAndHasWidgetId) {
|
||||||
switch (message.data.message_kind) {
|
switch (message.data.message_kind) {
|
||||||
case 'info_return':
|
case 'info_return':
|
||||||
const promise_array = this.message_wait[message.data.command];
|
const promise_array = this.message_wait[message.data.command];
|
||||||
|
Loading…
Reference in New Issue
Block a user