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

1 line
6.4 KiB
JavaScript

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.createVodPlayerController=exports.VodPlayerController=void 0;var _types=require("./types"),_miniSdkConfig=require("./mini-sdk-config");function _typeof(t){return _typeof="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},_typeof(t)}function ownKeys(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,i)}return r}function _objectSpread(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(Object(r),!0).forEach(function(e){_defineProperty(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function _defineProperty(t,e,r){return(e=_toPropertyKey(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,_toPropertyKey(i.key),i)}}function _createClass(t,e,r){return e&&_defineProperties(t.prototype,e),r&&_defineProperties(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function _toPropertyKey(t){var e=_toPrimitive(t,"string");return"symbol"===_typeof(e)?e:String(e)}function _toPrimitive(t,e){if("object"!==_typeof(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var i=r.call(t,e||"default");if("object"!==_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}var VodPlayerController=function(){function t(e){_classCallCheck(this,t),this._getStore=e.getStore,this._getSdkInstance=e.getSdkInstance,this._getStateManager=e.getStateManager,this._getStatsReporter=e.getStatsReporter,this._getCurrentTime=e.getCurrentTime,this._setData=e.setData,this._onFailure=e.onFailure,this._vodContextGetter=e.vodContextGetter,this._getVideoType=e.getVideoType,this._firstFrameTimer=null}return _createClass(t,[{key:"state",get:function(){return this._getStateManager().vodState}},{key:"config",get:function(){return(0,_miniSdkConfig.getMiniSdkVideoConfig)(this._getStore())}},{key:"_reportTea",value:function(t,e){var r,i,a=null===(r=this._getSdkInstance)||void 0===r||null===(i=r.call(this))||void 0===i?void 0:i.reportTea;"function"==typeof a&&a(t,_objectSpread({videoType:_types.VideoType.VOD},e||{}))}},{key:"clearTimers",value:function(){this._firstFrameTimer&&(clearTimeout(this._firstFrameTimer),this._firstFrameTimer=null)}},{key:"startPlay",value:function(t){var e=t.vid,r=t.playUrl,i=t.backupUrl,a=t.useBackup;this.clearTimers();var o=Date.now(),n=this.state;n.attemptId+=1,n.params={startPlay:o,firstFrame:0,vid:e,playUrl:r},n.attemptReportedFailed=!1,a?n.usingBackup=!0:(n.switchPending=null,n.switchRetryIndex=0,n.usingBackup=!1,n.backupUrl=i||""),this._reportTea("mini_vod_start_play",{startPlay:o,vid:e,playUrl:r,backupUrl:i,useBackup:a}),this._startFirstFrameTimeout(n.attemptId,r,e)}},{key:"_startFirstFrameTimeout",value:function(t,e,r){var i=this,a=this.config.stability,o=t;this._firstFrameTimer=setTimeout(function(){var t=i.state;t.attemptId===o&&(t.params.firstFrame||i.handleFailure({code:1e4,msg:"first frame timeout",url:e,vid:r},{reason:_types.FailureReason.FAIL_TIMEOUT}))},a.firstFrameTimeoutMs)}},{key:"trySwitchStream",value:function(t){var e,r,i,a=this,o=this.state,n=this.config.strategy;if(null==n||!n.enableStreamSwitch)return!1;if(o.usingBackup)return!1;var s=o.backupUrl;if(!s)return!1;var l=Date.now(),u=(o.switchRetryIndex||0)+1;o.switchRetryIndex=u,o.switchPending={startMs:l,from_primary:!0,reason:t,retry_index:u},this._reportTea("mini_sdk_vod_switch_url_start",o.switchPending),this._getStore().set("reportInfo.isPlay",!1),null===(e=this._getStatsReporter())||void 0===e||e.stopHeartbeat(t);var p=null===(r=o.params)||void 0===r?void 0:r.vid;this.startPlay({vid:p,playUrl:s,useBackup:!0});var c=(null===(i=this._getCurrentTime)||void 0===i?void 0:i.call(this))||0;return this._setData({videoType:""}),setTimeout(function(){a._setData({videoType:_types.VideoType.VOD,vodSrc:s,vodInitialTime:c})}),!0}},{key:"handleFailure",value:function(t,e){var r,i,a=Date.now(),o=(null==e?void 0:e.reason)||"unknown",n=this.state;return n.params.firstFrame||!n.params.startPlay||n.attemptReportedFailed||(n.attemptReportedFailed=!0,this._reportTea("mini_vod_start_play_failed",{error:t,duration:a-n.params.startPlay,playUrl:n.params.playUrl,vid:n.params.vid})),n.usingBackup&&n.switchPending&&(this._reportTea("mini_sdk_vod_switch_url_error",_objectSpread(_objectSpread({},n.switchPending),{},{durationMs:a-(n.switchPending.startMs||a),error:t,reason:o})),n.switchPending=null),!!this.trySwitchStream(o)||(this._getStore().set("reportInfo.isPlay",!1),null===(r=this._getStatsReporter())||void 0===r||r.stopHeartbeat(o),null===(i=this._onFailure)||void 0===i||i.call(this,t,o),this.clearTimers(),!1)}},{key:"onLoadedMetaData",value:function(){var t,e,r=this.state;if(this._getVideoType()===_types.VideoType.VOD&&!r.params.firstFrame&&r.params.startPlay){if(r.switchPending){var i=Date.now();this._reportTea("mini_sdk_vod_switch_url_success",_objectSpread(_objectSpread({},r.switchPending),{},{durationMs:i-(r.switchPending.startMs||i)})),r.switchPending=null}this.clearTimers(),r.params.firstFrame=Date.now();var a=this._getStore(),o=Number(null==a||null===(t=a.get)||void 0===t?void 0:t.call(a,"reportInfo.sdkInitRequestStartMs"))||0,n=o&&o<=r.params.startPlay?o:r.params.startPlay;this._reportTea("mini_vod_start_play_success",{firstFrame:Math.max(0,r.params.firstFrame-r.params.startPlay),firstFrameEndToEnd:Math.max(0,r.params.firstFrame-n),playUrl:r.params.playUrl,vid:r.params.vid}),null==a||null===(e=a.set)||void 0===e||e.call(a,"reportInfo.sdkInitRequestStartMs",0)}}},{key:"reset",value:function(){this.clearTimers(),this._getStateManager().resetVodRuntimeState()}}]),t}();exports.VodPlayerController=VodPlayerController;var createVodPlayerController=function(t){return new VodPlayerController(t)};exports.createVodPlayerController=createVodPlayerController;