Files
ruo-shan-cloud-pharmacy/miniprogram/package-live/volc-mini-sdk/components/player/player.js
T
陈誉午 994b267f5c feat: 电子药箱小程序 - 4Tab药品管理
- 电子药箱: 药品库存管理 + 手动录入 + 今日用药打卡
- 药品百科: 搜索 + 分类筛选 + 20种药品静态数据
- 惠教中心: 4条药品使用指南课程
- 我的: 家庭成员信息管理
- 自定义TabBar + navigation-bar组件
- SVG药品分类插图
2026-07-29 11:20:52 +08:00

1 line
62 KiB
JavaScript

"use strict";var _constant=require("../../utils/constant"),_utils=require("./utils"),_events=_interopRequireDefault(require("../../utils/events")),_singleLogin=require("../../utils/singleLogin"),_utils2=require("../../utils/utils"),_stats=_interopRequireDefault(require("./stats")),_miniSdkConfig=require("./mini-sdk-config"),_stateManager=require("./state-manager"),_livePlayerController=require("./live-player-controller"),_vodPlayerController=require("./vod-player-controller"),_types=require("./types"),_constants=require("./constants"),_liveUtils=require("./live-utils"),_pseudoLive=require("./pseudo-live"),_notification=require("../../utils/notification"),_peopleCount=require("../../utils/people-count"),_bottomIcon=require("../../utils/icons/bottom-icon"),_backgroundPlayback=require("./background-playback");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}function _createForOfIteratorHelper(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!i){if(Array.isArray(e)||(i=_unsupportedIterableToArray(e))||t&&e&&"number"==typeof e.length){i&&(e=i);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,r=!0,l=!1;return{s:function(){i=i.call(e)},n:function(){var e=i.next();return r=e.done,e},e:function(e){l=!0,a=e},f:function(){try{r||null==i.return||i.return()}finally{if(l)throw a}}}}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}function _regeneratorRuntime(){_regeneratorRuntime=function(){return e};var e={},t=Object.prototype,i=t.hasOwnProperty,n=Object.defineProperty||function(e,t,i){e[t]=i.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",r=o.asyncIterator||"@@asyncIterator",l=o.toStringTag||"@@toStringTag";function s(e,t,i){return Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,i){return e[t]=i}}function d(e,t,i,o){var a=t&&t.prototype instanceof c?t:c,r=Object.create(a.prototype),l=new T(o||[]);return n(r,"_invoke",{value:L(e,i,l)}),r}function u(e,t,i){try{return{type:"normal",arg:e.call(t,i)}}catch(e){return{type:"throw",arg:e}}}e.wrap=d;var v={};function c(){}function h(){}function p(){}var y={};s(y,a,function(){return this});var f=Object.getPrototypeOf,_=f&&f(f(k([])));_&&_!==t&&i.call(_,a)&&(y=_);var g=p.prototype=c.prototype=Object.create(y);function P(e){["next","throw","return"].forEach(function(t){s(e,t,function(e){return this._invoke(t,e)})})}function m(e,t){function o(n,a,r,l){var s=u(e[n],e,a);if("throw"!==s.type){var d=s.arg,v=d.value;return v&&"object"==_typeof(v)&&i.call(v,"__await")?t.resolve(v.__await).then(function(e){o("next",e,r,l)},function(e){o("throw",e,r,l)}):t.resolve(v).then(function(e){d.value=e,r(d)},function(e){return o("throw",e,r,l)})}l(s.arg)}var a;n(this,"_invoke",{value:function(e,i){function n(){return new t(function(t,n){o(e,i,t,n)})}return a=a?a.then(n,n):n()}})}function L(e,t,i){var n="suspendedStart";return function(o,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw a;return{value:void 0,done:!0}}for(i.method=o,i.arg=a;;){var r=i.delegate;if(r){var l=I(r,i);if(l){if(l===v)continue;return l}}if("next"===i.method)i.sent=i._sent=i.arg;else if("throw"===i.method){if("suspendedStart"===n)throw n="completed",i.arg;i.dispatchException(i.arg)}else"return"===i.method&&i.abrupt("return",i.arg);n="executing";var s=u(e,t,i);if("normal"===s.type){if(n=i.done?"completed":"suspendedYield",s.arg===v)continue;return{value:s.arg,done:i.done}}"throw"===s.type&&(n="completed",i.method="throw",i.arg=s.arg)}}}function I(e,t){var i=t.method,n=e.iterator[i];if(void 0===n)return t.delegate=null,"throw"===i&&e.iterator.return&&(t.method="return",t.arg=void 0,I(e,t),"throw"===t.method)||"return"!==i&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+i+"' method")),v;var o=u(n,e.iterator,t.arg);if("throw"===o.type)return t.method="throw",t.arg=o.arg,t.delegate=null,v;var a=o.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,v):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,v)}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function C(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function k(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,o=function t(){for(;++n<e.length;)if(i.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:b}}function b(){return{value:void 0,done:!0}}return h.prototype=p,n(g,"constructor",{value:p,configurable:!0}),n(p,"constructor",{value:h,configurable:!0}),h.displayName=s(p,l,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===h||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,s(e,l,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},P(m.prototype),s(m.prototype,r,function(){return this}),e.AsyncIterator=m,e.async=function(t,i,n,o,a){void 0===a&&(a=Promise);var r=new m(d(t,i,n,o),a);return e.isGeneratorFunction(i)?r:r.next().then(function(e){return e.done?e.value:r.next()})},P(g),s(g,l,"Generator"),s(g,a,function(){return this}),s(g,"toString",function(){return"[object Generator]"}),e.keys=function(e){var t=Object(e),i=[];for(var n in t)i.push(n);return i.reverse(),function e(){for(;i.length;){var n=i.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=k,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(C),!e)for(var t in this)"t"===t.charAt(0)&&i.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(i,n){return r.type="throw",r.arg=e,t.next=i,n&&(t.method="next",t.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],r=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var l=i.call(a,"catchLoc"),s=i.call(a,"finallyLoc");if(l&&s){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(l){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&i.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var r=a?a.completion:{};return r.type=e,r.arg=t,a?(this.method="next",this.next=a.finallyLoc,v):this.complete(r)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),v},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var i=this.tryEntries[t];if(i.finallyLoc===e)return this.complete(i.completion,i.afterLoc),C(i),v}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var i=this.tryEntries[t];if(i.tryLoc===e){var n=i.completion;if("throw"===n.type){var o=n.arg;C(i)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,i){return this.delegate={iterator:k(e),resultName:t,nextLoc:i},"next"===this.method&&(this.arg=void 0),v}},e}function asyncGeneratorStep(e,t,i,n,o,a,r){try{var l=e[a](r),s=l.value}catch(e){return void i(e)}l.done?t(s):Promise.resolve(s).then(n,o)}function _asyncToGenerator(e){return function(){var t=this,i=arguments;return new Promise(function(n,o){var a=e.apply(t,i);function r(e){asyncGeneratorStep(a,n,o,r,l,"next",e)}function l(e){asyncGeneratorStep(a,n,o,r,l,"throw",e)}r(void 0)})}}function ownKeys(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),i.push.apply(i,n)}return i}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(i),!0).forEach(function(t){_defineProperty(e,t,i[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):ownKeys(Object(i)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})}return e}function _defineProperty(e,t,i){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function _toPropertyKey(e){var t=_toPrimitive(e,"string");return"symbol"===_typeof(t)?t:String(t)}function _toPrimitive(e,t){if("object"!==_typeof(e)||null===e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var n=i.call(e,t||"default");if("object"!==_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}var storeKey="liveInfo",defaultVideoAttrs={controls:!0,autoplay:!0,"show-progress":!0,"enable-progress-gesture":!0,"picture-in-picture-mode":["push","pop"],"enable-play-gesture":!0,"show-play-btn":!0,"show-center-play-btn":!1},defaultLivePlayerAttrs={"picture-in-picture-mode":["push","pop"]},ORIENTATION={PORTRAIT:"portrait",LANDSCAPE:"landscape"},VIDEO_RECREATE_RETRY_MAX=3,VIDEO_RECREATE_TEA_EVENT="mini_sdk_video_recreate",BACKGROUND_PLAYBACK_APP_HIDE_GUARD_MS=1e4,toOrientation=function(e){return e?ORIENTATION.PORTRAIT:ORIENTATION.LANDSCAPE},isPlayableVideoType=function(e){return e===_types.VideoType.LIVE||e===_types.VideoType.VOD},resolveCoverImageUrl=function(e,t){return e?t?(null==e?void 0:e.VerticalCoverImageUrl)||(null==e?void 0:e.CoverImageUrl)||"":(null==e?void 0:e.CoverImageUrl)||"":""},resolveUserObjectFit=function(e,t){var i=t.activityOrientationConfig,n=t.videoOrientation,o=t.liveEngine;return"function"==typeof e?e({activityOrientationConfig:i,videoOrientation:n,liveEngine:o}):e};Component({options:{multipleSlots:!0},properties:{isPortrait:{type:Boolean,value:!0},sdkInstance:{type:Object,value:null}},data:{activityId:"",videoType:"",vid:"",vodSrc:"",CoverImageUrl:"",status:-1,statusCh:"",replayInfo:[],replayIndex:-1,PreviewVideoUrl:"",previewPromptEnable:!1,previewPromptText:"",showStatusBanner:!1,statusBannerText:"",statusBannerCentered:!1,showStatusTag:!1,statusTagText:"",liveSrc:"",liveUrlList:[],liveEngine:_constant.BUILD_VIDEO_ONLY?"video":"live-player",liveSuccessCode:_constants.LIVE_SUCCESS_CODE_DEFAULT,playRate:1,isVideoPortrait:!0,videoStyle:"",liveAllowedSize:[{key:"auto",value:"智能",url:""}],liveSelectedSize:"auto",vodAllowedSize:[{key:"auto",value:"智能",url:""}],vodSelectedSize:"auto",vodInitialTime:0,videoControlsVisible:!0,isFullscreen:!1,backRateList:[{key:"0.5",value:"0.5x"},{key:"1",value:"1x"},{key:"1.25",value:"1.25x"},{key:"1.5",value:"1.5x"},{key:"2",value:"2x"}],isLoading:!1,isShowReplayBtn:!1,vodAutoplay:!0,shouldRenderLivePlayer:!0,shouldRenderVodPlayer:!0,trailerLoop:!1,videoAttrs:defaultVideoAttrs,livePlayerAttrs:defaultLivePlayerAttrs,playErrorVisible:!1,playErrorText:"",isDesktopPlatform:!1,showPeopleCount:!1},observers:{sdkInstance:function(e){var t,i=this;if(e){var n=e.store;this.sdkInstance=e,this.sdkInstance.setPlayerInstance(this),this.bindIconClick(),this.store=n,n.set("player",{controlBarDisplay:!1,isVideoPortrait:!0});var o=this;"function"==typeof this._unsub&&this._unsub(),this._unsub=null,this._unsub=n.get((_defineProperty(t={},storeKey,function(e){var t,a,r,l,s;if(e){(0,_notification.syncNotificationState)(n,e);var d=!(null==e||null===(t=e.Basic)||void 0===t||!t.IsPreviewPromptEnable),u=(null==e||null===(a=e.Basic)||void 0===a?void 0:a.PreviewPrompt)||"";i.data.activityId!==e.ActivityId&&e.ActivityId&&o.init.bind(i)();var v=i.data.status!==(null==e||null===(r=e.Basic)||void 0===r?void 0:r.Status);v?o.handleLiveStatus.bind(i)():i.data.previewPromptEnable===d&&i.data.previewPromptText===u||o.syncStatusBanner.bind(i)(null==e?void 0:e.Basic),i.data.PreviewVideoUrl!==(null==e||null===(l=e.Basic)||void 0===l?void 0:l.PreviewVideoUrl)&&o.handlePreviewVideoUrlUpdate.bind(i)(),o.handleReplayInfoUpdate.bind(i)(null==e?void 0:e.Basic);var c,h,p=resolveCoverImageUrl(null==e?void 0:e.Basic,i.data.isPortrait);(0,_utils2.setDataIfChanged)(i,{CoverImageUrl:p,showPeopleCount:(0,_peopleCount.shouldShowPeopleCount)(e)}),!v&&null!==(s=i._pseudoLiveState)&&void 0!==s&&s.enabled&&(i._syncPseudoLiveRuntime(e),null!==(c=i.store)&&void 0!==c&&null!==(h=c.get)&&void 0!==h&&h.call(c,"reportInfo.isPlay")&&(i._recordPseudoLiveSeekGap("live_info_sync"),i._runPseudoLiveChase(void 0,"live_info_sync")));var y=i._getReplayPlayerConfig(e),f=y?JSON.stringify(y):"";f!==i._lastReplayPlayerConfigKey&&(i._lastReplayPlayerConfigKey=f,i.syncComponentAttrs())}}),_defineProperty(t,"mainInfo",function(){i.syncComponentAttrs()}),_defineProperty(t,"networkInfo",function(e){i._handleNetworkInfoChange(e)}),t)),this.syncComponentAttrs()}},videoType:function(e){var t,i,n,o,a;null===(t=this._getLivePlayerComponent)||void 0===t||null===(i=t.call(this))||void 0===i||null===(n=i.exitFullScreen)||void 0===n||n.call(i),null===(o=this.videoContext)||void 0===o||null===(a=o.exitFullScreen)||void 0===a||a.call(o),(0,_utils2.setDataIfChanged)(this,{isFullscreen:!1});var r=this._stateManager;r.videoType=e;var l,s,d,u,v,c,h,p=r.lastVideoType,y=r.isPrevPlayable();isPlayableVideoType(e),this.syncComponentAttrs(),y&&p!==e&&(null===(l=this._stats)||void 0===l||l.stopHeartbeat("switch_".concat(p,"_to_").concat(e)),null===(s=this.store)||void 0===s||null===(d=s.set)||void 0===d||d.call(s,"reportInfo.isPlay",!1),null===(u=this.sdkInstance)||void 0===u||null===(v=u.emit)||void 0===v||v.call(u,_events.default.PUBLIC.player.destroy)),p===_types.VideoType.LIVE&&e!==_types.VideoType.LIVE&&(null===(c=this._liveController)||void 0===c||c.clearTimers(),this._resetPseudoLiveState()),p===_types.VideoType.VOD&&e!==_types.VideoType.VOD&&(null===(h=this._vodController)||void 0===h||h.reset()),e!==_types.VideoType.VOD||this.videoContext||(this.videoContext=wx.createVideoContext("volcVodPlayer",this))},liveSrc:function(e){var t;e&&(null===(t=this._liveController)||void 0===t||t.onSrcChange(e))},isVideoPortrait:function(e,t){e!==t&&this.syncComponentAttrs()},isPortrait:function(e,t){if(e!==t){var i,n,o=null===(i=this.store)||void 0===i||null===(n=i.get)||void 0===n?void 0:n.call(i,storeKey+".Basic"),a=resolveCoverImageUrl(o,e);(0,_utils2.setDataIfChanged)(this,{CoverImageUrl:a}),this.syncComponentAttrs()}},liveEngine:function(e,t){e!==t&&this.syncComponentAttrs()}},lifetimes:{created:function(){this._stateManager=(0,_stateManager.createPlayerStateManager)(),this._stats=null,this.liveLastReport=-1e6,this.vodPlayTime=0,this._liveEngineMode=_constants.LIVE_ENGINE_MODE_DEFAULT,this._lastReplayPlayerConfigKey="",this._lastReplayInfoKey="",this._shouldResumeOnAppShow=!1,this._appHideAt=0,this._shouldRecreateVideoOnPageShow=!1,this._isPageHidden=!1,this._liveVideoRecreateRetryCount=0,this._vodRecreateRetryCount=0,this._pseudoLiveState=(0,_pseudoLive.createPseudoLiveState)()},attached:function(){var e,t;(0,_singleLogin.updatePlayerInstance)(this),this._initializeManagers(),this._initPlatformState(),"function"==typeof(null===(e=wx)||void 0===e?void 0:e.onAppHide)&&(this._boundHandleAppHide=this._handleAppHide.bind(this),wx.onAppHide(this._boundHandleAppHide)),"function"==typeof(null===(t=wx)||void 0===t?void 0:t.onAppShow)&&(this._boundHandleAppShow=this._handleAppShow.bind(this),wx.onAppShow(this._boundHandleAppShow))},detached:function(){var e,t,i,n,o,a,r,l,s,d,u,v;"function"==typeof this._unsub&&this._unsub(),this._unsub=null,this.unbindIconClick(),"function"==typeof(null===(e=wx)||void 0===e?void 0:e.offAppHide)&&this._boundHandleAppHide&&wx.offAppHide(this._boundHandleAppHide),"function"==typeof(null===(t=wx)||void 0===t?void 0:t.offAppShow)&&this._boundHandleAppShow&&wx.offAppShow(this._boundHandleAppShow),null===(i=this._liveController)||void 0===i||i.clearTimers(),null===(n=this._vodController)||void 0===n||n.clearTimers(),this._clearVodWaitingEndTimer(),null===(o=this._getLivePlayerComponent)||void 0===o||null===(a=o.call(this))||void 0===a||null===(r=a.stopAll)||void 0===r||r.call(a),isPlayableVideoType(this.data.videoType)&&(null===(u=this.sdkInstance)||void 0===u||null===(v=u.emit)||void 0===v||v.call(u,_events.default.PUBLIC.player.destroy)),null===(l=this.sdkInstance)||void 0===l||l.setPlayerInstance(null),null===(s=this._stats)||void 0===s||s.stopHeartbeat("detached"),null===(d=this._stats)||void 0===d||d.dispose(),(0,_singleLogin.updatePlayerInstance)(null),this._stats=null}},pageLifetimes:{show:function(){this._handlePageShow()},hide:function(){this._handlePageHide()}},methods:{_shouldManualResumeVideoPlayback:function(){return this.data.videoType===_types.VideoType.VOD||this.data.videoType===_types.VideoType.LIVE&&"video"===this.data.liveEngine},_resetPseudoLiveState:function(){this._pseudoLiveState=(0,_pseudoLive.createPseudoLiveState)()},_getPseudoLivePayload:function(){var e,t,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null===(e=this.store)||void 0===e||null===(t=e.get)||void 0===t?void 0:t.call(e,storeKey);return(0,_pseudoLive.getPseudoLivePayload)(i)},_getReplayPlayerConfig:function(){var e,t,i,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null===(e=this.store)||void 0===e||null===(t=e.get)||void 0===t?void 0:t.call(e,storeKey);return(null==n?void 0:n.ReplayPlayerConfig)||(null==n||null===(i=n.Basic)||void 0===i?void 0:i.ReplayPlayerConfig)||null},_isPseudoLiveEnabled:function(){return!!this._getPseudoLivePayload()},_isPseudoLiveLine:function(e){return Array.isArray(null==e?void 0:e.VideoPlayList)&&e.VideoPlayList.length>0},_isReportingPseudoLive:function(){var e,t,i;return!(null===(e=this._pseudoLiveState)||void 0===e||!e.enabled)||this._isPseudoLiveLine(null===(t=this._stateManager)||void 0===t||null===(i=t.liveState)||void 0===i?void 0:i.line)},_syncPseudoLiveRuntime:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=(0,_pseudoLive.syncPseudoLiveRuntime)(this._pseudoLiveState,e,t);return i?(this._pseudoLiveState=i,i):(this._resetPseudoLiveState(),null)},_resetReplayButton:function(){(0,_utils2.setDataIfChanged)(this,{isShowReplayBtn:!1})},_setVodAutoplay:function(e){(0,_utils2.setDataIfChanged)(this,{vodAutoplay:e})},_showToast:function(e){try{wx&&"function"==typeof wx.showToast&&wx.showToast({title:e,icon:"none"})}catch(e){}},_handleNetworkInfoChange:function(e){var t;this.data.videoType===_types.VideoType.LIVE&&(null===(t=this._liveController)||void 0===t||t.handleNetworkStatusChange(e))},openBackRateDrawer:function(){var e,t;null===(e=this.selectComponent("#volc-backRate-drawer"))||void 0===e||null===(t=e.showFrame)||void 0===t||t.call(e)},openClarityDrawer:function(){var e,t;null===(e=this.selectComponent("#volc-clarity-drawer"))||void 0===e||null===(t=e.showFrame)||void 0===t||t.call(e)},_initPlatformState:function(){try{var e,t=(("function"==typeof(null===(e=wx)||void 0===e?void 0:e.getSystemInfoSync)?wx.getSystemInfoSync():{})||{}).platform,i="windows"===t||"mac"===t;i!==this.data.isDesktopPlatform&&this.setData({isDesktopPlatform:i})}catch(e){}},canRecreateVideoOnAppShow:function(){var e;return(0,_utils.isDeviceMatchRulesMatched)(null===(e=(0,_miniSdkConfig.getMiniSdkVideoRecreateConfig)(this.store))||void 0===e?void 0:e.appShowRecreateDevices)},canRecreateVideoOnPageShow:function(){var e;return(0,_utils.isDeviceMatchRulesMatched)(null===(e=(0,_miniSdkConfig.getMiniSdkVideoRecreateConfig)(this.store))||void 0===e?void 0:e.pageShowRecreateDevices)},canRecreateVideoOnError:function(){var e;return(0,_utils.isDeviceMatchRulesMatched)(null===(e=(0,_miniSdkConfig.getMiniSdkVideoRecreateConfig)(this.store))||void 0===e?void 0:e.videoErrorCallbackRecreateDevices)},canRecreateVideoOnUnexpectedPause:function(){var e;return!1!==(null===(e=(0,_miniSdkConfig.getMiniSdkVideoRecreateConfig)(this.store))||void 0===e?void 0:e.unexpectedPauseRecreate)},_initializeManagers:function(){var e=this,t=this._stateManager;this._stats=new _stats.default({getSdkInstance:function(){return e.sdkInstance},getVideoType:function(){return e.data.videoType},getCurrentTime:function(){return e.vodPlayTime||0},getPlayUrl:function(){return e.data.videoType===_types.VideoType.LIVE?e.data.liveSrc:e.data.videoType===_types.VideoType.VOD?e.data.vodSrc:""},getDefinition:function(){return e.data.videoType===_types.VideoType.LIVE?t.liveState.definition||e.data.liveSelectedSize||"":e.data.videoType===_types.VideoType.VOD&&e.data.vodSelectedSize||""},getSelectedDefinition:function(){return e.data.videoType===_types.VideoType.LIVE?e.data.liveSelectedSize||"":e.data.videoType===_types.VideoType.VOD&&e.data.vodSelectedSize||""},getLiveEngine:function(){return e.data.liveEngine},getActivityOrientationConfig:function(){return toOrientation(!!e.data.isPortrait)},getIsPseudoLive:function(){return e._isReportingPseudoLive()},isPlaying:function(){var t;return null===(t=e.store)||void 0===t?void 0:t.get("reportInfo.isPlay")}}),this._liveController=(0,_livePlayerController.createLivePlayerController)({getStore:function(){return e.store},getSdkInstance:function(){return e.sdkInstance},getStateManager:function(){return t},getStatsReporter:function(){return e._stats},getLiveSelectedSize:function(){return e.data.liveSelectedSize},getLiveEngine:function(){return e.data.liveEngine},getLiveEngineMode:function(){return e._liveEngineMode},getIsPseudoLive:function(){return e._isReportingPseudoLive()},switchLiveEngine:function(t,i){return e._switchLiveEngine(t,i)},setData:function(t){return e.setData(t)},onFailure:function(t,i){var n,o;null===(n=e.sdkInstance)||void 0===n||null===(o=n.emit)||void 0===o||o.call(n,_events.default.PUBLIC.player.error,{error:t,reason:i,kind:"live",liveEngine:e.data.liveEngine})},setPlayError:function(t,i){return e._setPlayError(t,i)},liveContextGetter:function(){var t;return null===(t=e._getLivePlayerComponent)||void 0===t?void 0:t.call(e)}}),this._vodController=(0,_vodPlayerController.createVodPlayerController)({getStore:function(){return e.store},getSdkInstance:function(){return e.sdkInstance},getStateManager:function(){return t},getStatsReporter:function(){return e._stats},getCurrentTime:function(){return e.vodPlayTime||0},setData:function(t){return e.setData(t)},getVideoType:function(){return e.data.videoType},onFailure:function(t,i){var n,o;null===(n=e.sdkInstance)||void 0===n||null===(o=n.emit)||void 0===o||o.call(n,_events.default.PUBLIC.player.error,{kind:"vod",error:t,reason:i})},vodContextGetter:function(){return e.videoContext||(e.videoContext=wx.createVideoContext("volcVodPlayer",e)),e.videoContext}})},syncComponentAttrs:function(){var e,t,i,n=(((null===(e=this.store)||void 0===e?void 0:e.get("mainInfo"))||{}).options||{}).mediaComponentsAttr||{},o=n.video,a=n.livePlayer,r=toOrientation(!!this.data.isPortrait),l=toOrientation(!!this.data.isVideoPortrait),s=this.data.liveEngine,d=r===ORIENTATION.LANDSCAPE?"contain":l===ORIENTATION.PORTRAIT?"cover":"contain",u="video"!==s&&"cover"===d?"fillCrop":d,v=_objectSpread(_objectSpread({},defaultVideoAttrs),(0,_utils2.omitUndefined)(o)),c=(0,_miniSdkConfig.getMiniSdkLiveConfig)(this.store),h=c.buffer,p=c.stability,y=_objectSpread(_objectSpread({},defaultLivePlayerAttrs),(0,_utils2.omitUndefined)(a)),f=null==o?void 0:o["object-fit"],_=resolveUserObjectFit(f,{activityOrientationConfig:r,videoOrientation:l,liveEngine:s});v["object-fit"]=_||d;var g=this.data.status===_constant.LIVE_STATUS.回放,P=null===(t=this._getReplayPlayerConfig)||void 0===t?void 0:t.call(this),m="0"!==String(null!==(i=null==P?void 0:P.IsProgressBarEnable)&&void 0!==i?i:"1");this.data.videoType===_types.VideoType.VOD&&g&&!m&&(v["show-progress"]=!1,v["enable-progress-gesture"]=!1,v["enable-play-gesture"]=!1);var L=null==a?void 0:a["object-fit"],I=resolveUserObjectFit(L,{activityOrientationConfig:r,videoOrientation:l,liveEngine:s});y["object-fit"]=I||u,void 0===y["min-cache"]&&(y["min-cache"]=h.minCache),void 0===y["max-cache"]&&(y["max-cache"]=h.maxCache),this.setData({videoAttrs:v,livePlayerAttrs:y,liveSuccessCode:(null==p?void 0:p.successCode)||_constants.LIVE_SUCCESS_CODE_DEFAULT})},_setPlayError:function(e,t){this.setData({playErrorVisible:!!e,playErrorText:e?t||"播放失败":""})},syncStatusBanner:function(e){var t=null==e?void 0:e.Status,i=_constant.LIVE_STATUS_TEXT_MAP[t]||"",n=!(null==e||!e.IsPreviewPromptEnable),o=(null==e?void 0:e.PreviewPrompt)||"",a=!(null==e||!e.PreviewVideoUrl),r=Object.prototype.hasOwnProperty.call(e||{},"IsPreviewPromptEnable"),l=!1,s="",d=!1,u=!1,v="";if(t===_constant.LIVE_STATUS.结束){var c=!(null==e||!e.IsGenerateReplay);l=c,s=c?"直播已结束,回放生成中":i,d=c,v=(u=!c&&!this.data.isPortrait)?i:""}else t===_constant.LIVE_STATUS.预告&&(u=!this.data.isPortrait,v=i,a||(r?(l=n,s=n?o||i:"",d=n):(l=!0,s=i,d=!0)));this.setData({previewPromptEnable:n,previewPromptText:o,showStatusBanner:l,statusBannerText:s,statusBannerCentered:d,showStatusTag:u,statusTagText:v})},_getLivePlayerComponent:function(){try{return this.selectComponent?this.selectComponent("#volcLivePlayer"):null}catch(e){return null}},canRequestBackgroundPlayback:function(){return(0,_backgroundPlayback.canRequestBackgroundPlayback)(this)},_isRecentBackgroundPlaybackAppHide:function(){var e,t,i=Number(this._backgroundPlaybackRequestedAt||0),n=!(null===(e=this.store)||void 0===e||null===(t=e.get)||void 0===t||!t.call(e,"reportInfo.isPlay"));return!!(i&&n&&this._shouldManualResumeVideoPlayback())&&Date.now()-i<BACKGROUND_PLAYBACK_APP_HIDE_GUARD_MS},_normalizeLiveEngine:function(e){return"video"===e?"video":"live-player"},_normalizeLiveEngineMode:function(e){return(0,_liveUtils.isValidLiveEngineMode)(e)?e:_constants.LIVE_ENGINE_MODE_DEFAULT},_getUserPreferredLiveEngineMode:function(){var e,t,i,n=(null===(e=this.store)||void 0===e||null===(t=e.get)||void 0===t?void 0:t.call(e,"mainInfo"))||{},o=null==n||null===(i=n.options)||void 0===i?void 0:i.liveEngineMode;return(0,_liveUtils.isValidLiveEngineMode)(o)?o:null},_resolveLiveEngine:function(e){var t;if(_constant.BUILD_VIDEO_ONLY)return{engine:"video",mode:"video"};var i,n=null===(t=(0,_miniSdkConfig.getMiniSdkLiveConfig)(this.store))||void 0===t?void 0:t.engine,o=this._getUserPreferredLiveEngineMode(),a=this._normalizeLiveEngineMode(null==n?void 0:n.mode);if(!o&&"auto"!==o&&(0,_utils.isForceUseVideoEngine)(null==n?void 0:n.forceUseVideoDevices))return null===(i=this.sdkInstance)||void 0===i||i.reportTea("mini_sdk_force_use_video_engine",{tccLiveEngineConfig:n,userLiveEngineMode:o}),{engine:"video",mode:"video"};var r=o||a,l=!!(null!=e&&e.FlvPlayList&&e.FlvPlayList.length||null!=e&&e.RtmpPlayList&&e.RtmpPlayList.length),s=!(null==e||!e.HlsPlayList||!e.HlsPlayList.length);return"auto"===r?l?{engine:"live-player",mode:r}:s?{engine:"video",mode:r}:{engine:"live-player",mode:r}:{engine:this._normalizeLiveEngine(r),mode:r}},_getLiveDefinitionUrl:function(e,t,i){if("video"===this._normalizeLiveEngine(i)){var n=((null==e?void 0:e.VideoPlayList)||[]).find(function(e){return e.definition===t}),o=((null==e?void 0:e.HlsPlayList)||[]).find(function(e){return e.definition===t}),a=n||o||{};return(0,_utils2.normalizePullUrl)(a.url||"")}var r=(null==e?void 0:e.FlvPlayList)||[],l=(null==e?void 0:e.RtmpPlayList)||[],s=r.find(function(e){return e.definition===t})||l.find(function(e){return e.definition===t})||{};return(0,_utils2.normalizePullUrl)(s.url||"")},_switchLiveEngine:function(e,t){var i,n,o,a,r=this;if(_constant.BUILD_VIDEO_ONLY)return!1;if("auto"!==this._liveEngineMode)return!1;var l=this._normalizeLiveEngine(e);if(l===this.data.liveEngine)return!1;var s=this.data.liveEngine,d=null===(i=this._stateManager)||void 0===i||null===(n=i.liveState)||void 0===n?void 0:n.line,u=Array.isArray(this.data.liveAllowedSize)?this.data.liveAllowedSize.map(function(e){return _objectSpread(_objectSpread({},e),{},{url:d?r._getLiveDefinitionUrl(d,e.key,l):e.url})}):this.data.liveAllowedSize;return this.setData({liveEngine:l,liveAllowedSize:u}),null===(o=this.sdkInstance)||void 0===o||null===(a=o.reportTea)||void 0===a||a.call(o,"mini_sdk_live_engine_switch",_objectSpread({from:s,to:l},t||{})),!0},exitPip:function(){var e=this.videoContext;try{e&&"function"==typeof e.exitPictureInPicture&&e.exitPictureInPicture()}catch(e){}try{var t,i,n;null===(t=this._getLivePlayerComponent)||void 0===t||null===(i=t.call(this))||void 0===i||null===(n=i.exitPictureInPicture)||void 0===n||n.call(i)}catch(e){}try{wx&&"function"==typeof wx.exitPictureInPicture&&wx.exitPictureInPicture()}catch(e){}},requestBackgroundPlayback:function(){var e,t,i,n,o=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).source||"api",a=(0,_backgroundPlayback.requestBackgroundPlayback)(this,o),r=a.ok,l=a.payload;return r?(this._backgroundPlaybackRequestedAt=Date.now(),null===(e=this.sdkInstance)||void 0===e||null===(t=e.emitEvent)||void 0===t||t.call(e,_events.default.PUBLIC.backgroundPlayback.success,l)):(null===(i=this.sdkInstance)||void 0===i||null===(n=i.emitEvent)||void 0===n||n.call(i,_events.default.PUBLIC.backgroundPlayback.fail,l),"bottom-icon"===o&&this._showToast("unsupported"===(null==l?void 0:l.reason)?"当前环境不支持后台播放":"后台播放开启失败")),l},pause:function(){var e,t,i,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.data.videoType===_types.VideoType.LIVE?null===(e=this._getLivePlayerComponent)||void 0===e||null===(t=e.call(this))||void 0===t||null===(i=t.pause)||void 0===i||i.call(t,n):this.data.videoType===_types.VideoType.VOD&&this.videoContext&&this.videoContext.pause()},play:function(){var e,t,i;this.data.videoType===_types.VideoType.LIVE?(null===(e=this._getLivePlayerComponent)||void 0===e||null===(t=e.call(this))||void 0===t||null===(i=t.play)||void 0===i||i.call(t),this.liveLastReport=-1e6):this.data.videoType===_types.VideoType.VOD&&this.videoContext&&this.videoContext.play()},handleRetryPull:function(){this.data.videoType===_types.VideoType.LIVE&&(this._isPseudoLiveEnabled()?this.updatePseudoLiveInfo():this.updateLiveInfo())},init:function(){var e=this.store.get(storeKey+".ActivityId");if(e&&e!==this.data.activityId){var t=this.store.get(storeKey+".Basic");this.setData({activityId:e,CoverImageUrl:resolveCoverImageUrl(t,this.data.isPortrait)}),this.sdkInstance.emit(_events.default.PUBLIC.player.init),this.handleLiveStatus()}},bindIconClick:function(){var e=this;this.unbindIconClick(),this.sdkInstance&&(this._boundBottomIconClick=function(t){var i,n=null==t||null===(i=t.icon)||void 0===i?void 0:i.key;"BACKRATE"===n&&e.openBackRateDrawer(),"CLARITY"===n&&e.openClarityDrawer(),n===_bottomIcon.BOTTOM_ICON_KEY.BACKGROUND_PLAYBACK&&e.requestBackgroundPlayback({source:"bottom-icon"})},this._iconClickSdkInstance=this.sdkInstance,this.sdkInstance.on(_events.default.PUBLIC.bottomIcon.click,this._boundBottomIconClick))},unbindIconClick:function(){var e,t;this._iconClickSdkInstance&&this._boundBottomIconClick&&(null===(e=(t=this._iconClickSdkInstance).off)||void 0===e||e.call(t,_events.default.PUBLIC.bottomIcon.click,this._boundBottomIconClick)),this._iconClickSdkInstance=null,this._boundBottomIconClick=null},videoErrorCallback:function(e){if(this._finishVodWaiting(),this.data.videoType===_types.VideoType.VOD){var t;if(this.canRecreateVideoOnError()&&this._vodRecreateRetryCount<VIDEO_RECREATE_RETRY_MAX&&this._recreateVodVideo("error_retry"))return void(this._vodRecreateRetryCount+=1);null===(t=this._vodController)||void 0===t||t.handleFailure(e,{reason:"vod_play_failed"})}},handleLiveStatus:function(){var e,t,i=this.store.get(storeKey+".Basic");if(i){var n=_constant.LIVE_STATUS_TEXT_MAP[i.Status]||"";switch(this.sdkInstance.emit(_events.default.PUBLIC.activity.status,i.Status),this.sdkInstance.emit(_events.default.PUBLIC.player.status,n),this._resetReplayButton(),this.setData({status:i.Status,statusCh:n}),this.syncStatusBanner(i),null===(e=this._liveController)||void 0===e||e.clearTimers(),null===(t=this._vodController)||void 0===t||t.clearTimers(),i.Status){case _constant.LIVE_STATUS.预告:this.handlePreviewVideoUrlUpdate();break;case _constant.LIVE_STATUS.直播:this._isPseudoLiveEnabled()?this.updatePseudoLiveInfo():this.updateLiveInfo();break;case _constant.LIVE_STATUS.回放:var o=(0,_utils.formatReplayLines)(i.Replays);this._lastReplayInfoKey=JSON.stringify(o),this.setData({replayInfo:o,replayIndex:-1}),this.playNextReplay();break;case _constant.LIVE_STATUS.结束:case _constant.LIVE_STATUS.已关闭:this.updateCoverInfo(resolveCoverImageUrl(i,this.data.isPortrait))}}},handleReplayInfoUpdate:function(e){if(e&&this.data.status===_constant.LIVE_STATUS.回放){var t=(0,_utils.formatReplayLines)(e.Replays),i=JSON.stringify(t);if(i!==this._lastReplayInfoKey){this._lastReplayInfoKey=i;var n=this.data.replayIndex,o=this.data.replayInfo[n],a=t[n];if(this.setData({replayInfo:t}),t.length){if(!a)return this.setData({replayIndex:-1}),void this.playNextReplay();null!=o&&o.vid&&null!=a&&a.vid&&o.vid!==a.vid&&this.updateVodInfo(a.vid)}else{var r,l,s,d;null!==(r=this.store)&&void 0!==r&&null!==(l=r.get)&&void 0!==l&&l.call(r,"reportInfo.isPlay")&&(this.store.set("reportInfo.isPlay",!1),null===(s=this._stats)||void 0===s||null===(d=s.stopHeartbeat)||void 0===d||d.call(s,"replay_removed")),this.updateVodInfo("")}}}},playNextReplay:function(){this.data.replayInfo.length?(this._setVodAutoplay(!0),this.data.replayInfo.length<=this.data.replayIndex+1?this.setData({replayIndex:0}):this.setData({replayIndex:this.data.replayIndex+1}),this.sdkInstance.emit(_events.default.PUBLIC.player.playNext,this.data.replayInfo[this.data.replayIndex]),this.updateVodInfo(this.data.replayInfo[this.data.replayIndex].vid)):this.updateVodInfo("")},handlePreviewVideoUrlUpdate:function(){var e=this.store.get("".concat(storeKey,".Basic.PreviewVideoUrl"))||"";this.setData({PreviewVideoUrl:e}),this.syncStatusBanner(this.store.get("".concat(storeKey,".Basic"))),this.data.status===_constant.LIVE_STATUS.预告?((0,_utils2.setDataIfChanged)(this,{trailerLoop:!0}),this.updateVodInfo(e)):(0,_utils2.setDataIfChanged)(this,{trailerLoop:!1})},_showVodPoster:function(){var e=resolveCoverImageUrl(this.store.get(storeKey+".Basic"),this.data.isPortrait);this.setData({videoType:"poster",isLoading:!1,vid:"",vodSrc:"",vodInitialTime:0,CoverImageUrl:e}),this.store.set("reportInfo.videoType","poster")},updateVodInfo:function(e){var t=this;return _asyncToGenerator(_regeneratorRuntime().mark(function i(){var n,o,a,r,l,s,d,u,v,c,h,p,y,f,_,g,P,m,L,I,S,C;return _regeneratorRuntime().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(t._resetReplayButton(),e){i.next=4;break}return t._showVodPoster(),i.abrupt("return");case 4:if(e!==t.data.vid){i.next=6;break}return i.abrupt("return");case 6:return t.vodPlayTime=0,t._setVodAutoplay(!0),t.setData({isLoading:!0}),i.prev=9,i.next=12,(0,_utils.getVodInfoByVid)(e,{request:function(e,i){return t.sdkInstance.requestStrict(e,i)},prefetchVodInfo:t.store.get("prefetchVodInfo"),activityId:t.data.activityId});case 12:o=i.sent,i.next=21;break;case 15:return i.prev=15,i.t0=i.catch(9),t.setData({isLoading:!1}),t.data.status===_constant.LIVE_STATUS.预告&&t._showVodPoster(),t.sdkInstance.emit(_events.default.PUBLIC.player.error,{kind:"vod",error:i.t0,reason:"get_vod_info_failed"}),i.abrupt("return");case 21:a={},o.list.forEach(function(e){null!=e&&e.definition&&(a[e.definition]=e.backupUrl||"")}),t._stateManager.vodState.backupMap=a,r=o.list.map(function(e){return{key:e.definition,value:e.text.zh,url:e.url}}),l=o.defaultDef,s=o.defaultUrl,d=o.defaultBackupUrl||a[o.defaultDef]||"",u=(0,_miniSdkConfig.getMiniSdkVideoConfig)(t.store),v=u.strategy,c=t.store.get("networkInfo"),h=(0,_utils2.isWeakNetwork)(c),p=t.store.get("devicePerformanceInfo"),y=!(0,_utils2.isHighPerformanceDevice)(p),f=v.reduceQualityOnWeakNetAtStart&&h,_=v.reduceQualityOnLowPerformanceDeviceAtStart&&y,g=o.list.map(function(e){return e.definition}),(f||_)&&(P=["1080p","720p","540p","360p"],(m=g.filter(function(e){return P.includes(e)}).sort(function(e,t){return P.indexOf(e)-P.indexOf(t)})).length>0&&(L=m[m.length-1],(I=o.list.find(function(e){return e.definition===L}))&&(l=L,s=I.url,d=a[L]||"",null===(S=t.sdkInstance)||void 0===S||null===(C=S.reportTea)||void 0===C||C.call(S,"mini_sdk_weak_network_low_quality_start",{networkInfo:c,isWeakNet:h,devicePerformanceInfo:p,startReason:f?"weak_network":"device_performance",selectedSize:L,allowedSize:g,selectedUrl:s,selectedBackupUrl:d,videoType:_types.VideoType.VOD})))),null===(n=t._vodController)||void 0===n||n.startPlay({vid:e,playUrl:s,backupUrl:d}),t.setData({videoType:_types.VideoType.VOD,isLoading:!1,vid:e,vodSrc:s,vodSelectedSize:l,vodAllowedSize:r,vodInitialTime:0}),t.store.set("reportInfo.videoType",_types.VideoType.VOD),t.setPortraitViewDisplay(o.height,o.width),t.videoContext||(t.videoContext=wx.createVideoContext("volcVodPlayer",t)),setTimeout(function(){t.videoContext.playbackRate(Number(t.data.playRate))},500);case 45:case"end":return i.stop()}},i,null,[[9,15]])}))()},handleVodAllowedSizeChange:function(e,t){var i,n,o,a,r=this;if(e!==this.data.vodSelectedSize){null===(i=this._stats)||void 0===i||null===(n=i.stopHeartbeat)||void 0===n||n.call(i,"vodDefinitionChange"),this.sdkInstance.emit(_events.default.PUBLIC.player.definitionChange,{size:e});var l=(null===(o=this._stateManager.vodState.backupMap)||void 0===o?void 0:o[e])||"";null===(a=this._vodController)||void 0===a||a.startPlay({vid:this.data.vid,playUrl:t,backupUrl:l}),this.setData({videoType:""}),setTimeout(function(){r.setData({videoType:_types.VideoType.VOD,vodSelectedSize:e,vodSrc:t,vodInitialTime:r.vodPlayTime||0})}),setTimeout(function(){r.videoContext.playbackRate(Number(r.data.playRate))},500),wx.showToast({title:"清晰度切换成功",icon:"none"})}},setPortraitViewDisplay:function(e,t){var i=e>t;if(this.setData({isVideoPortrait:i}),this.store.set("player.isVideoPortrait",i),this.data.isPortrait&&!i){var n=100/t*e;this.setData({videoStyle:"position: absolute; top: 10%; padding-top: ".concat(n,"%; height: 0;"),isLoading:!1})}else this.setData({videoStyle:"",isLoading:!1})},updateCoverInfo:function(e){this._resetPseudoLiveState(),this._resetReplayButton(),this.setData({videoType:"poster",vid:"",CoverImageUrl:e}),this.store.set("reportInfo.videoType","poster")},_resolveLivePlayDefinitionForAuto:function(e,t){var i,n,o=(0,_miniSdkConfig.getMiniSdkLiveConfig)(this.store).strategy,a=this.store.get("networkInfo"),r=(0,_utils2.isWeakNetwork)(a),l=this.store.get("devicePerformanceInfo"),s=!(0,_utils2.isHighPerformanceDevice)(l),d=o.reduceQualityOnWeakNetAtStart&&r,u=o.reduceQualityOnLowPerformanceDeviceAtStart&&s;if(!d&&!u)return{playDefinition:"auto"};var v=(Array.isArray(null==e?void 0:e.SizeList)?e.SizeList:[]).filter(function(e){return e&&"auto"!==e}),c=v[v.length-1];return c?(null===(i=this.sdkInstance)||void 0===i||null===(n=i.reportTea)||void 0===n||n.call(i,"mini_sdk_weak_network_low_quality_start",{networkInfo:a,isWeakNet:r,devicePerformanceInfo:l,allowedSize:t,liveEngine:this.data.liveEngine,startReason:d?"weak_network":"device_performance",selectedSize:c,videoType:_types.VideoType.LIVE}),{playDefinition:c}):{playDefinition:"auto"}},updateLiveInfo:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this._resetPseudoLiveState(),this._resetReplayButton(),this.liveLastReport=-1e6;var i=(0,_utils.formatLiveLines)(this.store.get("PullStreamUrl"))[t];if(i){var n,o=this._resolveLiveEngine(i),a=o.engine,r=o.mode,l=new Set,s=[],d=_createForOfIteratorHelper(i.AllowedSize);try{for(d.s();!(n=d.n()).done;){var u,v=n.value;l.has(v)||(l.add(v),s.push({key:v,value:(null===(u=_utils.LiveDefinitionMap[v])||void 0===u?void 0:u[0])||v,url:this._getLiveDefinitionUrl(i,v,a)}))}}catch(e){d.e(e)}finally{d.f()}var c=this.data.liveSelectedSize||"auto";l.has(c)||(c="auto");var h=c;"auto"===c&&(h=this._resolveLivePlayDefinitionForAuto(i,s).playDefinition||"auto"),this._liveEngineMode=r,this.setData({videoType:_types.VideoType.LIVE,videoStyle:"opacity: 0",liveAllowedSize:s,liveSelectedSize:c,liveEngine:a,isLoading:!0,vid:""}),null===(e=this._liveController)||void 0===e||e.startPlay(i,t,h,"init"),this.store.set("reportInfo.videoType",_types.VideoType.LIVE)}else console.error("直播线路异常")},updatePseudoLiveInfo:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this._resetReplayButton(),this.liveLastReport=-1e6;var i=this.store.get(storeKey),n=(0,_utils.formatPseudoLiveLines)(null==i?void 0:i.VodLoopVideoConfig)[t];if(n){this._syncPseudoLiveRuntime(i,{currentLineIndex:t,resetLocalLoop:!0,pendingInitialSeek:!0}),this.vodPlayTime=0;var o,a=new Set,r=[],l=_createForOfIteratorHelper(n.AllowedSize);try{for(l.s();!(o=l.n()).done;){var s,d,u=o.value;a.has(u)||(a.add(u),r.push({key:u,value:(null===(s=_utils.LiveDefinitionMap[u])||void 0===s?void 0:s[0])||(null===(d=_utils.VodDefinitionMap[u])||void 0===d?void 0:d[0])||u,url:this._getLiveDefinitionUrl(n,u,"video")}))}}catch(e){l.e(e)}finally{l.f()}var v=this.data.liveSelectedSize||"auto";a.has(v)||(v="auto");var c=v;if("auto"===v){var h=this._resolveLivePlayDefinitionForAuto(n,r);c=h.playDefinition||"auto"}this.setData({videoType:_types.VideoType.LIVE,videoStyle:"opacity: 0",liveAllowedSize:r,liveSelectedSize:v,liveEngine:"video",isLoading:!0,vid:""},function(){var i;null===(i=e._liveController)||void 0===i||i.startPlay(n,t,c,"init")}),this._liveEngineMode="video",this.store.set("reportInfo.videoType",_types.VideoType.LIVE)}else this.updateLiveInfo(t)},handleLiveAllowedSizeChange:function(e,t){if(e!==this.data.liveSelectedSize){var i={size:e,url:t,prevSize:this.data.liveSelectedSize};this.sdkInstance.emit(_events.default.PUBLIC.player.definitionChange,i),this.sdkInstance.reportTea("mini_sdk_live_size_change",i),this.setData({liveSelectedSize:e});var n=this._stateManager,o=n.liveState.line,a=n.liveState.lineIndex||0;if(o){var r,l=e;"auto"===e&&(l=this._resolveLivePlayDefinitionForAuto(o,this.data.liveAllowedSize).playDefinition||"auto"),null===(r=this._liveController)||void 0===r||r.startPlay(o,a,l,"manual_definition")}wx.showToast({title:"清晰度切换成功",icon:"none"})}},bindVodEnded:function(){var e;null===(e=this._stats)||void 0===e||e.stopHeartbeat("vod_ended"),this.setData({vodInitialTime:0}),this.data.status===_constant.LIVE_STATUS.回放&&(this.data.replayInfo.length>this.data.replayIndex+1?(this.playNextReplay(),this.sdkInstance.emit(_events.default.PUBLIC.player.ended,!1)):(this.store.set("reportInfo.isPlay",!1),this.setData({isShowReplayBtn:!0,vodAutoplay:!1}),this.sdkInstance.emit(_events.default.PUBLIC.player.ended,!0)))},liveErrorCallback:function(e){var t,i=(null==e?void 0:e.detail)||e||{},n=(null==i?void 0:i.raw)||i;null===(t=this._liveController)||void 0===t||t.handleFailure(n,{reason:"live_error"})},liveNetStatus:function(e){var t,i,n,o,a,r,l,s,d,u,v,c,h,p,y,f=this._stateManager;f.liveState.lastNetStatusInfo=(null==e||null===(t=e.detail)||void 0===t?void 0:t.info)||null;var _,g,P,m,L=null==e||null===(i=e.detail)||void 0===i||null===(n=i.info)||void 0===n?void 0:n.videoFPS,I="live-player"===this.data.liveEngine&&!(null!==(o=this._stats)&&void 0!==o&&null!==(a=o.isHeartbeatRunning)&&void 0!==a&&a.call(o));this._liveNetStatusPositiveFpsCount=I&&L>0?(this._liveNetStatusPositiveFpsCount||0)+1:0,I&&this._liveNetStatusPositiveFpsCount>3&&(this._liveNetStatusPositiveFpsCount=0,null===(_=this.store)||void 0===_||null===(g=_.set)||void 0===g||g.call(_,"reportInfo.isPlay",!0),null===(P=this._stats)||void 0===P||null===(m=P.startHeartbeat)||void 0===m||m.call(P));var S=null==e||null===(r=e.detail)||void 0===r||null===(l=r.info)||void 0===l?void 0:l.videoHeight,C=null==e||null===(s=e.detail)||void 0===s||null===(d=s.info)||void 0===d?void 0:d.videoWidth;null===(u=this.sdkInstance)||void 0===u||null===(v=u.reportTea)||void 0===v||v.call(u,"mini_sdk_live_net_status",_objectSpread({time:Date.now(),activityId:null===(c=this.store)||void 0===c||null===(h=c.get)||void 0===h||null===(p=h.call(c,"liveInfo"))||void 0===p?void 0:p.ActivityId,videoType:"live",activityStatus:this.data.status,liveSession:f.getLiveSessionSnapshot()},(null==e||null===(y=e.detail)||void 0===y?void 0:y.info)||{})),this.liveLastReport<0&&S&&C&&(this.liveLastReport=e.timeStamp,this.setPortraitViewDisplay(S,C)),this.sdkInstance.emit(_events.default.PUBLIC.player.networkChange,e.detail)},liveStateChange:function(e){var t,i=(null==e?void 0:e.detail)||{};null===(t=this._liveController)||void 0===t||t.handleStateChange(i),this.sdkInstance.emit(_events.default.PUBLIC.player.stateChange,i)},liveFirstFrame:function(e){var t,i,n=(null==e?void 0:e.detail)||{};this._liveVideoRecreateRetryCount=0,(0,_utils2.setDataIfChanged)(this,{isLoading:!1}),null===(t=this._liveController)||void 0===t||t.onSuccess({code:null!==(i=n.code)&&void 0!==i?i:0})},liveWaiting:function(e){var t;null===(t=this._liveController)||void 0===t||t.handleWaiting()},liveWaitingEnd:function(e){var t;null===(t=this._liveController)||void 0===t||t.handleWaitingEnd(null==e?void 0:e.detail),this.sdkInstance.emit(_events.default.PUBLIC.player.playing)},liveRetry:function(e){var t,i,n=(null==e?void 0:e.detail)||{};null===(t=this.sdkInstance)||void 0===t||null===(i=t.reportTea)||void 0===i||i.call(t,"mini_sdk_live_video_retry",n),"video_error_retry"===(null==n?void 0:n.reason)&&this.canRecreateVideoOnError()&&this._liveVideoRecreateRetryCount<VIDEO_RECREATE_RETRY_MAX&&this._recreateLiveVideoPlayer("error_retry")&&(this._liveVideoRecreateRetryCount+=1)},liveLoadedMetaData:function(e){var t,i,n=(null==e?void 0:e.detail)||{},o=null==n?void 0:n.width,a=null==n?void 0:n.height;if(o&&a&&this.setPortraitViewDisplay(a,o),null!==(t=this._pseudoLiveState)&&void 0!==t&&t.enabled&&this._pseudoLiveState.pendingInitialSeek){var r=Number(this._pseudoLiveState.seekTime||0);this._pseudoLiveState.pendingInitialSeek=!1,this._pseudoLiveState.finalEnded=!1,this._applyPseudoLivePlaybackRate(1,{force:!0}),r>0&&this._seekPseudoLive(r)}else if(null!==(i=this._pseudoLiveState)&&void 0!==i&&i.enabled){var l=(0,_pseudoLive.estimatePseudoLiveCurrentTime)(this._pseudoLiveState);l>0&&this._seekPseudoLive(l)}},_seekPseudoLive:function(e){var t,i,n,o,a,r=Number(e);return!(!Number.isFinite(r)||r<0||(null===(t=this._getLivePlayerComponent)||void 0===t||null===(i=t.call(this))||void 0===i||null===(n=i.call)||void 0===n||n.call(i,"seek",r),(0,_pseudoLive.syncPseudoLivePlayhead)(this._pseudoLiveState,r,{playing:!(null===(o=this.store)||void 0===o||null===(a=o.get)||void 0===a||!a.call(o,"reportInfo.isPlay"))}),0))},_applyPseudoLivePlaybackRate:function(e){var t,i,n,o,a,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},l=Number(e);if(!Number.isFinite(l)||l<=0)return!1;var s=Number(this._pseudoLiveState.playbackRate||1);return!(!r.force&&this._pseudoLiveState.playbackRate===l||((0,_pseudoLive.syncPseudoLivePlayhead)(this._pseudoLiveState,void 0,{playing:!(null===(t=this.store)||void 0===t||null===(i=t.get)||void 0===i||!i.call(t,"reportInfo.isPlay")),playbackRate:l}),null===(n=this._getLivePlayerComponent)||void 0===n||null===(o=n.call(this))||void 0===o||null===(a=o.call)||void 0===a||a.call(o,"playbackRate",l),s!==l&&this.sdkInstance.emit(_events.default.PUBLIC.player.ratechange,l),0))},_recordPseudoLiveChaseAction:function(e,t,i,n){var o,a,r,l=Number(null!==(o=null==e?void 0:e.gapTime)&&void 0!==o?o:Number((null==t?void 0:t.seekTime)||0)-i);null===(a=this._stats)||void 0===a||null===(r=a.recordLiveStateEvent)||void 0===r||r.call(a,_types.LiveStateCode.PLAY_PROGRESS,"pseudo live chase action",{source:"pseudo_live_chase",trigger:n,reason:null==e?void 0:e.reason,pseudoLiveAction:null==e?void 0:e.type,seekTime:null==e?void 0:e.time,playbackRate:null==e?void 0:e.rate,currentTime:i,targetSeekTime:null==t?void 0:t.seekTime,targetTime:null==e?void 0:e.targetTime,gapTime:l,currentLoopNumber:null==t?void 0:t.currentLoopNumber,totalLoopNumber:null==t?void 0:t.totalLoopNumber,localLoopNumber:null==t?void 0:t.localLoopNumber})},_recordPseudoLiveSeekGap:function(e){var t,i,n=this._pseudoLiveState;if(null!=n&&n.enabled){var o=(0,_pseudoLive.estimatePseudoLiveCurrentTime)(n),a=Number(n.seekTime||0);null===(t=this._stats)||void 0===t||null===(i=t.recordLiveStateEvent)||void 0===i||i.call(t,_types.LiveStateCode.PLAY_PROGRESS,"pseudo live seek gap",{source:"pseudo_live_seek_gap",trigger:e,seekTime:a,currentTime:o,gapTime:a-o,playbackRate:n.playbackRate,currentLoopNumber:n.currentLoopNumber,totalLoopNumber:n.totalLoopNumber,localLoopNumber:n.localLoopNumber})}},_runPseudoLiveChase:function(e,t){var i;if(null!==(i=this._pseudoLiveState)&&void 0!==i&&i.enabled){var n,o=this._pseudoLiveState,a=Number.isFinite(Number(e))&&void 0!==e?Number(e):(0,_pseudoLive.estimatePseudoLiveCurrentTime)(o),r=_createForOfIteratorHelper((0,_pseudoLive.resolvePseudoLiveTimeUpdateActions)(o,a));try{for(r.s();!(n=r.n()).done;){var l=n.value,s=!1;l.type===_pseudoLive.PseudoLiveTimeUpdateAction.SEEK?s=this._seekPseudoLive(l.time):l.type===_pseudoLive.PseudoLiveTimeUpdateAction.PLAYBACK_RATE?s=this._applyPseudoLivePlaybackRate(l.rate):l.type===_pseudoLive.PseudoLiveTimeUpdateAction.FINISH&&this._finishPseudoLivePlayback(),s&&this._recordPseudoLiveChaseAction(l,o,a,t)}}catch(e){r.e(e)}finally{r.f()}}},_finishPseudoLivePlayback:function(){var e,t;null!==(e=this._pseudoLiveState)&&void 0!==e&&e.enabled&&!this._pseudoLiveState.finalEnded&&(this._pseudoLiveState.finalEnded=!0,this._applyPseudoLivePlaybackRate(1,{force:!0}),this.store.set("reportInfo.isPlay",!1),null===(t=this._stats)||void 0===t||t.stopHeartbeat("pseudo_live_ended"),this.sdkInstance.emit(_events.default.PUBLIC.player.ended,!0))},liveTimeUpdate:function(e){var t,i=(null==e?void 0:e.detail)||{};null===(t=this._stats)||void 0===t||t.stopLoading(),this.vodPlayTime=Number((null==i?void 0:i.currentTime)||0),this.sdkInstance.emit(_events.default.PUBLIC.player.timeupdate,i)},liveEnded:function(){var e,t;if(null===(e=this._pseudoLiveState)||void 0===e||!e.enabled)return this.store.set("reportInfo.isPlay",!1),null===(t=this._stats)||void 0===t||t.stopHeartbeat("live_ended"),void this.sdkInstance.emit(_events.default.PUBLIC.player.ended,!0);var i=this._pseudoLiveState;if(i.localLoopNumber<i.totalLoopNumber)return i.localLoopNumber+=1,i.currentLoopNumber=i.localLoopNumber,i.seekTime=i.offset,i.finalEnded=!1,this._applyPseudoLivePlaybackRate(1,{force:!0}),this._seekPseudoLive(i.offset),this.play(),void this.sdkInstance.emit(_events.default.PUBLIC.player.ended,!1);this._finishPseudoLivePlayback()},handleVodPlayBackRateChange:function(e){this.videoContext||(this.videoContext=wx.createVideoContext("volcVodPlayer",this));var t=Number(e);this.setData({playRate:t}),this.videoContext.playbackRate(t),this.sdkInstance.emit(_events.default.PUBLIC.player.ratechange,t),this._showToast("倍速切换成功")},handleControlDisplay:function(e){var t,i=null==e||null===(t=e.detail)||void 0===t?void 0:t.show;"boolean"==typeof i&&this.setData({videoControlsVisible:i}),this.data.isPortrait&&this.store.set("player.controlBarDisplay",e.detail.show),this.sdkInstance.emit(_events.default.PUBLIC.player.controlsChange,e.detail)},backRateClick:function(){this.openBackRateDrawer()},clarityClick:function(){this.openClarityDrawer()},valueChange:function(e){var t,i,n=e.detail,o=n.item,a=n.type,r=o.key,l=o.url;if("backRate"===a)this.handleVodPlayBackRateChange(r),null===(t=this.selectComponent("#volc-backRate-drawer"))||void 0===t||null===(i=t.hideFrame)||void 0===i||i.call(t);else if("clarity"===a){var s,d;this.data.videoType===_types.VideoType.VOD?this.handleVodAllowedSizeChange(r,l):this.data.videoType===_types.VideoType.LIVE&&this.handleLiveAllowedSizeChange(r,l),null===(s=this.selectComponent("#volc-clarity-drawer"))||void 0===s||null===(d=s.hideFrame)||void 0===d||d.call(s)}},bindFullscreenChange:function(e){var t,i=null==e||null===(t=e.detail)||void 0===t?void 0:t.fullScreen;"boolean"==typeof i&&(0,_utils2.setDataIfChanged)(this,{isFullscreen:i}),this.sdkInstance.emit(_events.default.PUBLIC.player.fullscreenChange,e.detail)},handelPlay:function(){var e,t;this._shouldResumeOnAppShow=!1,this.store.set("reportInfo.isPlay",!0),null===(e=this._stats)||void 0===e||e.startHeartbeat(),this.data.videoType===_types.VideoType.VOD&&(this.data.vodInitialTime&&this.videoContext.seek(this.data.vodInitialTime),this.videoContext.playbackRate(Number(this.data.playRate))),null!==(t=this._pseudoLiveState)&&void 0!==t&&t.enabled&&(this._pseudoLiveState.finalEnded=!1,(0,_pseudoLive.syncPseudoLivePlayhead)(this._pseudoLiveState,void 0,{playing:!0}),this._runPseudoLiveChase(void 0,"play")),this.sdkInstance.emit(_events.default.PUBLIC.player.play),this.sdkInstance.emit(_events.default.PUBLIC.player.playing)},handelPause:function(e){var t,i,n,o,a=(null==e?void 0:e.detail)||{},r=!(null===(t=this.store)||void 0===t||null===(i=t.get)||void 0===i||!i.call(t,"reportInfo.isPlay")),l=this.data.videoType===_types.VideoType.LIVE&&r&&!this._isPageHidden&&!0!==(null==a?void 0:a.userInitiated)&&"native"===(null==a?void 0:a.pauseSource);l&&this._reportUnexpectedLivePause(a),null!==(n=this._pseudoLiveState)&&void 0!==n&&n.enabled&&(0,_pseudoLive.syncPseudoLivePlayhead)(this._pseudoLiveState,void 0,{playing:!1}),this.store.set("reportInfo.isPlay",!1),null===(o=this._stats)||void 0===o||o.stopHeartbeat("pause"),this.sdkInstance.emit(_events.default.PUBLIC.player.pause),l&&this.data.isPortrait&&"video"===this.data.liveEngine&&this.canRecreateVideoOnUnexpectedPause()&&this._recreateLiveVideoPlayer("unexpected_pause")},_reportUnexpectedLivePause:function(){var e,t,i,n,o,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};null===(e=this.sdkInstance)||void 0===e||null===(t=e.reportTea)||void 0===t||t.call(e,"mini_sdk_live_unexpected_pause",{videoType:this.data.videoType,liveEngine:this.data.liveEngine,orientation:toOrientation(!!this.data.isPortrait),videoOrientation:toOrientation(!!this.data.isVideoPortrait),unexpectedPauseRecreate:!1!==(null===(i=(0,_miniSdkConfig.getMiniSdkVideoRecreateConfig)(this.store))||void 0===i?void 0:i.unexpectedPauseRecreate),pauseSource:a.pauseSource||"unknown",src:this.data.liveSrc,liveSession:null===(n=this._stateManager)||void 0===n||null===(o=n.getLiveSessionSnapshot)||void 0===o?void 0:o.call(n),raw:a.raw})},_isCurrentVideoEngine:function(){return this.data.videoType===_types.VideoType.VOD||this.data.videoType===_types.VideoType.LIVE&&"video"===this.data.liveEngine},_recreateVodVideo:function(e){var t,i,n=this;if(this.data.videoType!==_types.VideoType.VOD)return!1;try{var o,a;null===(o=this.videoContext)||void 0===o||null===(a=o.stop)||void 0===a||a.call(o)}catch(e){}this.videoContext=null;var r=this.vodPlayTime||this.data.vodInitialTime||0;return this.setData({shouldRenderVodPlayer:!1,vodInitialTime:r,isLoading:!0},function(){var e,t,i=(null===(e=n._stateManager)||void 0===e?void 0:e.vodState)||{};null===(t=n._vodController)||void 0===t||t.startPlay({vid:n.data.vid,playUrl:n.data.vodSrc,backupUrl:i.backupUrl,useBackup:!!i.usingBackup}),n.setData({shouldRenderVodPlayer:!0},function(){setTimeout(function(){n.data.videoType===_types.VideoType.VOD&&n.data.shouldRenderVodPlayer&&(n.videoContext||(n.videoContext=wx.createVideoContext("volcVodPlayer",n)),n.videoContext.play())},50)})}),null===(t=this.sdkInstance)||void 0===t||null===(i=t.reportTea)||void 0===i||i.call(t,VIDEO_RECREATE_TEA_EVENT,{source:e,currentTime:r,videoType:this.data.videoType,liveEngine:this.data.liveEngine,src:this.data.vodSrc}),!0},_recreateLiveVideoPlayer:function(e){var t,i,n,o,a,r=this;if(this.data.videoType!==_types.VideoType.LIVE||"video"!==this.data.liveEngine)return!1;var l=null===(t=this._getLivePlayerComponent)||void 0===t?void 0:t.call(this);try{var s;null==l||null===(s=l.stopAll)||void 0===s||s.call(l)}catch(e){}return this.liveLastReport=-1e6,this.setData({shouldRenderLivePlayer:!1,isLoading:!0},function(){var e;null===(e=r._liveController)||void 0===e||e.onSrcChange(r.data.liveSrc),r.setData({shouldRenderLivePlayer:!0},function(){setTimeout(function(){var e,t,i;r.data.videoType===_types.VideoType.LIVE&&r.data.shouldRenderLivePlayer&&(null===(e=r._getLivePlayerComponent)||void 0===e||null===(t=e.call(r))||void 0===t||null===(i=t.play)||void 0===i||i.call(t))},50)})}),null===(i=this.sdkInstance)||void 0===i||null===(n=i.reportTea)||void 0===n||n.call(i,VIDEO_RECREATE_TEA_EVENT,{source:e,liveEngine:this.data.liveEngine,videoType:this.data.videoType,src:this.data.liveSrc,liveSession:null===(o=this._stateManager)||void 0===o||null===(a=o.getLiveSessionSnapshot)||void 0===a?void 0:a.call(o)}),!0},_recreateCurrentVideo:function(e){return!!this._isCurrentVideoEngine()&&(this.data.videoType===_types.VideoType.LIVE?this._recreateLiveVideoPlayer(e):this._recreateVodVideo(e))},_tryRecreateVideoOnAppShow:function(){var e,t=this._appHideAt?Math.max(0,Date.now()-this._appHideAt):0,i=null===(e=(0,_miniSdkConfig.getMiniSdkVideoRecreateConfig)(this.store))||void 0===e?void 0:e.backgroundThresholdMs;return!!(this.canRecreateVideoOnAppShow()&&this._isCurrentVideoEngine()&&t>=i)&&this._recreateCurrentVideo("app_show")},_handleAppHide:function(){var e,t,i,n;this._appHideAt=Date.now();var o,a,r=!(null===(e=this.store)||void 0===e||null===(t=e.get)||void 0===t||!t.call(e,"reportInfo.isPlay"));if(this._isRecentBackgroundPlaybackAppHide())return this._shouldResumeOnAppShow=!1,void(null===(o=this.sdkInstance)||void 0===o||null===(a=o.reportTea)||void 0===a||a.call(o,"mini_sdk_background_playback_skip_recent_app_hide_pause",{videoType:this.data.videoType,liveEngine:this.data.liveEngine}));if(this._shouldResumeOnAppShow=r&&this._shouldManualResumeVideoPlayback(),this._shouldResumeOnAppShow)this.pause({pauseSource:"app_hide"}),this._shouldResumeOnAppShow=!0;else if(r){var l,s,d,u;null===(l=this.store)||void 0===l||null===(s=l.set)||void 0===s||s.call(l,"reportInfo.isPlay",!1),null===(d=this._stats)||void 0===d||null===(u=d.stopHeartbeat)||void 0===u||u.call(d,"page_hide")}null===(i=this._liveController)||void 0===i||i.clearTimers(),null===(n=this._vodController)||void 0===n||n.clearTimers()},_handleAppShow:function(){this._shouldResumeOnAppShow&&(this._shouldResumeOnAppShow=!1,this._shouldRecreateVideoOnPageShow=!1,this._tryRecreateVideoOnAppShow()||this.play())},_handlePageHide:function(){var e,t,i,n;this._isPageHidden=!0,this._shouldRecreateVideoOnPageShow=this._isCurrentVideoEngine(),null===(e=this.sdkInstance)||void 0===e||null===(t=e.reportTea)||void 0===t||t.call(e,"mini_sdk_player_page_hide",{videoType:this.data.videoType,liveEngine:this.data.liveEngine,status:this.data.status,isPlaying:!(null===(i=this.store)||void 0===i||null===(n=i.get)||void 0===n||!n.call(i,"reportInfo.isPlay")),isCurrentVideoEngine:this._isCurrentVideoEngine(),shouldRecreateVideoOnPageShow:this._shouldRecreateVideoOnPageShow})},_handlePageShow:function(){var e,t,i,n;this._isPageHidden=!1,this._backgroundPlaybackRequestedAt=0;var o=!!this._shouldRecreateVideoOnPageShow,a=o&&this.canRecreateVideoOnPageShow();null===(e=this.sdkInstance)||void 0===e||null===(t=e.reportTea)||void 0===t||t.call(e,"mini_sdk_player_page_show",{videoType:this.data.videoType,liveEngine:this.data.liveEngine,status:this.data.status,isPlaying:!(null===(i=this.store)||void 0===i||null===(n=i.get)||void 0===n||!n.call(i,"reportInfo.isPlay")),isCurrentVideoEngine:this._isCurrentVideoEngine(),shouldRecreateVideoOnPageShow:o,canRecreateVideoOnPageShow:a,willRecreateVideoOnPageShow:o&&a}),o&&(this._shouldRecreateVideoOnPageShow=!1,a&&this._recreateCurrentVideo("page_show"))},handleClickReplay:function(){this._setVodAutoplay(!0),0===this.data.replayIndex?this.videoContext.play():this.playNextReplay(),this.setData({isShowReplayBtn:!1})},_clearVodWaitingEndTimer:function(){this._vodWaitingEndTimer&&(clearTimeout(this._vodWaitingEndTimer),this._vodWaitingEndTimer=null)},_finishVodWaiting:function(){var e;this._clearVodWaitingEndTimer(),null===(e=this._stats)||void 0===e||e.stopLoading(),(0,_utils2.setDataIfChanged)(this,{isLoading:!1})},_scheduleVodWaitingEndFallback:function(){var e=this;this._clearVodWaitingEndTimer(),this._vodWaitingEndTimer=setTimeout(function(){e._finishVodWaiting()},_constants.VIDEO_WAITING_END_TIMEOUT_MS)},handleVodTimeUpdate:function(e){var t,i=null===(t=this._stats)||void 0===t?void 0:t.isLoading();this._finishVodWaiting(),i&&this.sdkInstance.emit(_events.default.PUBLIC.player.playing),this.vodPlayTime=e.detail.currentTime,this.sdkInstance.emit(_events.default.PUBLIC.player.timeupdate,e.detail)},handleWaiting:function(){var e,t,i;null===(e=this._stats)||void 0===e||null===(t=e.recordWaiting)||void 0===t||t.call(e),null===(i=this._stats)||void 0===i||i.startLoading(),this._scheduleVodWaitingEndFallback(),this.sdkInstance.emit(_events.default.PUBLIC.player.waiting)},handleProgress:function(e){var t,i=null===(t=this._stats)||void 0===t?void 0:t.isLoading();this._finishVodWaiting(),i&&this.sdkInstance.emit(_events.default.PUBLIC.player.playing),this.sdkInstance.emit(_events.default.PUBLIC.player.progress,e.detail)},handleLoadedMetaData:function(e){var t;this._finishVodWaiting(),this._vodRecreateRetryCount=0,null===(t=this._vodController)||void 0===t||t.onLoadedMetaData(),this.sdkInstance.emit(_events.default.PUBLIC.player.loadedMetadata,e.detail)},handleEnterPictureInPicture:function(){this.sdkInstance.emit(_events.default.PUBLIC.player.pipChange,!0)},handleLeavePictureInPicture:function(){this.sdkInstance.emit(_events.default.PUBLIC.player.pipChange,!1)},handleSeekComplete:function(e){this.sdkInstance.emit(_events.default.PUBLIC.player.seeking,e.detail)}}});