mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-26 17:01:20 -08:00
add auto pip mode
This commit is contained in:
1 parent
8dc8dc3a3e
commit
6c0a198f02
9 files changed
+83
-31
No files matched your search
Vendored
+1
-1
@@ -5,4 +5,4 @@
|
||||
* Released under the MIT License.
|
||||
*/
|
||||
|
||||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).Artplayer=e()}(this,function(){"use strict";var a=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")};function r(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var i=function(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),t};"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function t(t,e){return t(e={exports:{}},e.exports),e.exports}var c=t(function(e){function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function r(t){return"function"==typeof Symbol&&"symbol"===n(Symbol.iterator)?e.exports=r=function(t){return n(t)}:e.exports=r=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":n(t)},r(t)}e.exports=r});var o=function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t};var s=function(t,e){return!e||"object"!==c(e)&&"function"!=typeof e?o(t):e},l=t(function(e){function n(t){return e.exports=n=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},n(t)}e.exports=n}),u=t(function(n){function r(t,e){return n.exports=r=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},r(t,e)}n.exports=r});var e=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&u(t,e)},f=t(function(t,e){function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function r(t){return t.constructor?t.constructor.name:null}function o(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:["option"];for(var r in s(t,e,n),l(t,e,n),u(t,e,n),e)if(Object.prototype.hasOwnProperty.call(e,r)){var i=t[r],o=e[r],a=n.concat(r);if(c(t,r,o,a))continue;s(i,o,a),l(i,o,a),u(i,o,a)}return t}function c(t,e,n,r){if(!Object.prototype.hasOwnProperty.call(t,e)){if(!0===n.__required__||!0===n.required)throw new TypeError("'".concat(r.join("."),"' is required"));return!0}}function s(t,e,n){var r;if("string"===a(e)?r=e:"function"===a(e)?e.___validator__=e:e.__type__?r=e.__type__:e.type&&(r=e.type),r&&"string"===a(r)){r=r.trim().toLowerCase();var i=a(t),o=i===r;if(-1<r.indexOf("|")&&(o=r.split("|").filter(Boolean).some(function(t){return i===t.trim()})),!o)throw new TypeError("'".concat(n.join("."),"' require '").concat(r,"' type, but got '").concat(i,"'"))}}function l(t,e,n){var r;if(e.___validator__?r=e.___validator__:e.validator&&(r=e.validator),"function"===a(r)){var i=r(t,a(t),n);if(!0!==i)throw new TypeError("The scheme for '".concat(n.join("."),"' validator function require return true, but got '").concat(i,"'"))}}function u(t,e,n){var r;if(e.___child__?r=e.___child__:e.child&&(r=e.child),"object"===a(r)){var i=a(t);"object"===i?o(t,r,n):"array"===i&&t.forEach(function(t,e){o(t,r,n.concat(e))})}}var i,a;t.exports=(i=Object.prototype.toString,o.kindOf=a=function(t){if(void 0===t)return"undefined";if(null===t)return"null";var e=n(t);if("boolean"===e)return"boolean";if("string"===e)return"string";if("number"===e)return"number";if("symbol"===e)return"symbol";if("function"===e)return function(t){return"GeneratorFunction"===r(t)}(t)?"generatorfunction":"function";if(function(t){return Array.isArray?Array.isArray(t):t instanceof Array}(t))return"array";if(function(t){return!(!t.constructor||"function"!=typeof t.constructor.isBuffer)&&t.constructor.isBuffer(t)}(t))return"buffer";if(function(t){try{if("number"==typeof t.length&&"function"==typeof t.callee)return!0}catch(t){if(-1!==t.message.indexOf("callee"))return!0}return!1}(t))return"arguments";if(function(t){return t instanceof Date||"function"==typeof t.toDateString&&"function"==typeof t.getDate&&"function"==typeof t.setDate}(t))return"date";if(function(t){return t instanceof Error||"string"==typeof t.message&&t.constructor&&"number"==typeof t.constructor.stackTraceLimit}(t))return"error";if(function(t){return t instanceof RegExp||"string"==typeof t.flags&&"boolean"==typeof t.ignoreCase&&"boolean"==typeof t.multiline&&"boolean"==typeof t.global}(t))return"regexp";switch(r(t)){case"Symbol":return"symbol";case"Promise":return"promise";case"WeakMap":return"weakmap";case"WeakSet":return"weakset";case"Map":return"map";case"Set":return"set";case"Int8Array":return"int8Line truncated
|
||||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).Artplayer=e()}(this,function(){"use strict";var a=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")};function r(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var i=function(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),t};"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function t(t,e){return t(e={exports:{}},e.exports),e.exports}var c=t(function(e){function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function r(t){return"function"==typeof Symbol&&"symbol"===n(Symbol.iterator)?e.exports=r=function(t){return n(t)}:e.exports=r=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":n(t)},r(t)}e.exports=r});var o=function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t};var s=function(t,e){return!e||"object"!==c(e)&&"function"!=typeof e?o(t):e},l=t(function(e){function n(t){return e.exports=n=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},n(t)}e.exports=n}),u=t(function(n){function r(t,e){return n.exports=r=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},r(t,e)}n.exports=r});var e=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&u(t,e)},f=t(function(t,e){function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function r(t){return t.constructor?t.constructor.name:null}function s(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:["option"];return l(t,e,n),u(t,e,n),function(o,a,c){var t=f(a),e=f(o);"object"===t&&"object"===e&&Object.keys(a).forEach(function(t){var e=o[t],n=a[t],r=c.slice();r.push(t),l(e,n,r),u(e,n,r),s(e,n,r)}),"array"===t&&"array"===e&&o.forEach(function(t,e){var n=o[e],r=a[e]||a[0],i=c.slice();i.push(e),l(n,r,i),u(n,r,i),s(n,r,i)})}(t,e,n),t}function l(t,e,n){if("string"===f(e)){var r=f(t);if(!(-1<e.indexOf("|")?e.split("|").map(function(t){return t.toLowerCase().trim()}).filter(Boolean).some(function(t){return r===t}):e.toLowerCase().trim()===r))throw new Error("[Type Error]: '".concat(n.join("."),"' require '").concat(e,"' type, but got '").concat(r,"'"))}}function u(t,e,n){if("function"===f(e)){var r=e(t,f(t),n);if(!0!==r){var i=f(r);throw"string"===i?new Error(r):"error"===i?r:new Error("[Validator Error]: The scheme for '".concat(n.join("."),"' validator require return true, but got '").concat(r,"'"))}}}var i,f;t.exports=(i=Object.prototype.toString,s.kindOf=f=function(t){if(void 0===t)return"undefined";if(null===t)return"null";var e=n(t);if("boolean"===e)return"boolean";if("string"===e)return"string";if("number"===e)return"number";if("symbol"===e)return"symbol";if("function"===e)return function(t){return"GeneratorFunction"===r(t)}(t)?"generatorfunction":"function";if(function(t){return Array.isArray?Array.isArray(t):t instanceof Array}(t))return"array";if(function(t){return!(!t.constructor||"function"!=typeof t.constructor.isBuffer)&&t.constructor.isBuffer(t)}(t))return"buffer";if(function(t){try{if("number"==typeof t.length&&"function"==typeof t.callee)return!0}catch(t){if(-1!==t.message.indexOf("callee"))return!0}return!1}(t))return"arguments";if(function(t){return t instanceof Date||"function"==typeof t.toDateString&&"function"==typeof t.getDate&&"function"==typeof t.setDate}(t))return"date";if(function(t){return t instanceof Error||"string"==typeof t.message&&t.constructor&&"number"==typeof t.constructor.stackTraceLimit}(t))return"error";if(function(t){return t instanceof RegExp||"string"==typeof t.flags&&"boolean"==typeof t.ignoreCase&&"boolean"==typeof t.multiline&&"boolean"==typeof t.global}(t))return"regexp";switch(r(t)){case"Symbol":return"symbol";case"Promise":return"promise";case"WeakMap":return"weakmap";case"WeakSet":return"weakset";case"Map":return"map";case"Set":return"set";case"Int8Array":return"int8array";case"Uint8Array":return"uint8array";case"Uint8ClampedArray":return"uint8clampedarray";case"Int16Array":return"int16array";case"Uint16Array":return"uint16array";case"Int32Array":return"int32array";case"Uint32Array":return"uint32array";case"Float32Array":return"float32array";case"Float64ArrayLine truncated
|
||||
@@ -121,6 +121,9 @@ class Artplayer extends Emitter {
|
||||
mutex: true,
|
||||
fullscreen: false,
|
||||
fullscreenWeb: false,
|
||||
miniProgressBar: true,
|
||||
localPreview: true,
|
||||
autoPip: true,
|
||||
layers: [],
|
||||
contextmenu: [],
|
||||
quality: [],
|
||||
|
||||
@@ -2,7 +2,6 @@ import { append, setStyle } from '../utils';
|
||||
|
||||
function nativePip(art, player) {
|
||||
const {
|
||||
notice,
|
||||
template: { $video },
|
||||
events: { proxy },
|
||||
} = art;
|
||||
@@ -16,12 +15,10 @@ function nativePip(art, player) {
|
||||
set(value) {
|
||||
if (value) {
|
||||
$video.requestPictureInPicture().catch(error => {
|
||||
notice.show(error, true, 3000);
|
||||
throw error;
|
||||
});
|
||||
} else {
|
||||
document.exitPictureInPicture().catch(error => {
|
||||
notice.show(error, true, 3000);
|
||||
throw error;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import { debounce } from '../utils';
|
||||
|
||||
export default function autoPip(art) {
|
||||
const { events, player, template } = art;
|
||||
const scrollDebounce = debounce(() => {
|
||||
const { top, height } = template.$player.getBoundingClientRect();
|
||||
if (top + height <= 0 && !player.pip && player.playing) {
|
||||
player.pip = true;
|
||||
} else if (player.pip) {
|
||||
player.pip = false;
|
||||
}
|
||||
}, 300);
|
||||
events.proxy(window, 'scroll', scrollDebounce);
|
||||
}
|
||||
@@ -2,21 +2,31 @@ import { errorHandle, hasOwnProperty } from '../utils';
|
||||
import subtitle from './subtitle';
|
||||
import localPreview from './localPreview';
|
||||
import miniProgressBar from './miniProgressBar';
|
||||
import autoPip from './autoPip';
|
||||
|
||||
export default class Plugins {
|
||||
constructor(art) {
|
||||
this.art = art;
|
||||
this.id = 0;
|
||||
|
||||
if (art.option.subtitle.url) {
|
||||
const { option } = art;
|
||||
|
||||
if (option.subtitle.url) {
|
||||
this.add(subtitle);
|
||||
}
|
||||
|
||||
if (!art.option.isLive) {
|
||||
if (!option.isLive && option.miniProgressBar) {
|
||||
this.add(miniProgressBar);
|
||||
}
|
||||
|
||||
this.add(localPreview);
|
||||
if (option.localPreview) {
|
||||
this.add(localPreview);
|
||||
}
|
||||
|
||||
if (option.pip && option.autoPip) {
|
||||
this.add(autoPip);
|
||||
}
|
||||
|
||||
art.option.plugins.forEach(plugin => {
|
||||
this.add(plugin);
|
||||
});
|
||||
|
||||
@@ -30,6 +30,8 @@ export default {
|
||||
mutex: 'boolean',
|
||||
fullscreen: 'boolean',
|
||||
fullscreenWeb: 'boolean',
|
||||
miniProgressBar: 'boolean',
|
||||
localPreview: 'boolean',
|
||||
plugins: ['function'],
|
||||
whitelist: ['string|function|regexp'],
|
||||
layers: [
|
||||
|
||||
Reference in new issue
Block a user