Skip to content

Commit

Permalink
Fix loadedFrame count for local files
Browse files Browse the repository at this point in the history
  • Loading branch information
hardiesoft committed May 13, 2021
1 parent 5ba8f51 commit c84f1ee
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 31 deletions.
26 changes: 15 additions & 11 deletions dist/CptvPlayerVue.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_

/***/ }),

/***/ 8987:
/***/ 6361:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
Expand Down Expand Up @@ -750,7 +750,7 @@ if (typeof window !== 'undefined') {
// Indicate to webpack that this file can be concatenated
/* harmony default export */ const setPublicPath = (null);

;// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"b2ba098c-vue-loader-template"}!./node_modules/vue-loader-v15/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js??ruleSet[0].rules[0].use[0]!./node_modules/vue-loader-v15/lib/index.js??vue-loader-options!./src/CptvPlayer.vue?vue&type=template&id=2ecd0be0&
;// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"b2ba098c-vue-loader-template"}!./node_modules/vue-loader-v15/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js??ruleSet[0].rules[0].use[0]!./node_modules/vue-loader-v15/lib/index.js??vue-loader-options!./src/CptvPlayer.vue?vue&type=template&id=f769d71a&
var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{class:['cptv-player', { 'stand-alone': _vm.standAlone }]},[_c('div',{key:"container",ref:"container",staticClass:"video-container"},[_c('canvas',{key:"base",ref:"canvas",class:['video-canvas', { smoothed: _vm.smoothed }]}),_c('canvas',{key:"overlay",ref:"overlayCanvas",staticClass:"overlay-canvas"}),_c('span',{key:"messaging",class:['player-messaging', { show: _vm.playerMessage !== null }],domProps:{"innerHTML":_vm._s(_vm.playerMessage)}}),_c('span',{directives:[{name:"show",rawName:"v-show",value:(_vm.showValueInfo),expression:"showValueInfo"}],key:"px-value",ref:"valueTooltip",staticClass:"value-tooltip"},[_vm._v(_vm._s(_vm.valueUnderCursor)+" ")]),(_vm.openUserDefinedCptvFile)?_c('div',{key:"openUserFile",staticClass:"playback-controls show"},[_c('b-form-file',{staticClass:"cptv-drop-area",attrs:{"accept":".cptv","state":_vm.userSuppliedFile !== null,"placeholder":"Choose a CPTV file or drop one here...","drop-placeholder":"Drop file here..."},model:{value:(_vm.userSuppliedFile),callback:function ($$v) {_vm.userSuppliedFile=$$v},expression:"userSuppliedFile"}})],1):_vm._e(),_c('div',{key:"buffering",class:[
'playback-controls',
{ show: _vm.isBuffering && !_vm.openUserDefinedCptvFile } ]},[_c('font-awesome-icon',{staticClass:"fa-spin buffering",attrs:{"icon":"spinner","size":"4x"}})],1),_c('div',{key:"playback-controls",class:[
Expand Down Expand Up @@ -13430,7 +13430,7 @@ var CptvPlayerComponent = /*#__PURE__*/function (_Vue) {
switch (_context2.prev = _context2.next) {
case 0:
if (this.totalFrames) {
_context2.next = 12;
_context2.next = 13;
break;
}

Expand All @@ -13445,19 +13445,20 @@ var CptvPlayerComponent = /*#__PURE__*/function (_Vue) {
break;
}

return _context2.abrupt("break", 12);
return _context2.abrupt("break", 13);

case 6:
CptvPlayervue_type_script_lang_ts_frames.push(frame);
_context2.next = 9;
this.loadedFrames = CptvPlayervue_type_script_lang_ts_frames.length;
_context2.next = 10;
return cptvDecoder.getTotalFrames();

case 9:
case 10:
this.totalFrames = _context2.sent;
_context2.next = 0;
break;

case 12:
case 13:
case "end":
return _context2.stop();
}
Expand Down Expand Up @@ -13613,7 +13614,8 @@ var CptvPlayerComponent = /*#__PURE__*/function (_Vue) {
}, {
key: "firstFrameForTrack",
value: function firstFrameForTrack(trackIndex) {
var frameForTrack = Object.entries(this.processedTracks).find(function (_ref4) {
var frameForTrack = Object.entries(this.processedTracks // eslint-disable-next-line @typescript-eslint/no-unused-vars
).find(function (_ref4) {
var _ref5 = _slicedToArray(_ref4, 2),
_ = _ref5[0],
tracks = _ref5[1];
Expand All @@ -13625,7 +13627,8 @@ var CptvPlayerComponent = /*#__PURE__*/function (_Vue) {
}, {
key: "onPastLastFrameForTrack",
value: function onPastLastFrameForTrack(trackIndex) {
var entries = Object.entries(this.processedTracks);
var entries = Object.entries(this.processedTracks); // eslint-disable-next-line @typescript-eslint/no-unused-vars

var firstFrameForTrackIndex = entries.findIndex(function (_ref6) {
var _ref7 = _slicedToArray(_ref6, 2),
_ = _ref7[0],
Expand All @@ -13634,7 +13637,8 @@ var CptvPlayerComponent = /*#__PURE__*/function (_Vue) {
return Object.keys(tracks).map(Number).includes(trackIndex);
});
var fromStartOfTrack = entries.slice(firstFrameForTrackIndex);
var onePastLastFrameForTrackIndex = fromStartOfTrack.findIndex(function (_ref8) {
var onePastLastFrameForTrackIndex = fromStartOfTrack.findIndex( // eslint-disable-next-line @typescript-eslint/no-unused-vars
function (_ref8) {
var _ref9 = _slicedToArray(_ref8, 2),
_ = _ref9[0],
tracks = _ref9[1];
Expand Down Expand Up @@ -25496,7 +25500,7 @@ try {
/******/ // startup
/******/ // Load entry module and return exports
/******/ // This entry module doesn't tell about it's top-level declarations so it can't be inlined
/******/ var __webpack_exports__ = __webpack_require__(8987);
/******/ var __webpack_exports__ = __webpack_require__(6361);
/******/ module.exports = __webpack_exports__.default;
/******/
/******/ })()
Expand Down
2 changes: 1 addition & 1 deletion dist/CptvPlayerVue.common.js.map

Large diffs are not rendered by default.

26 changes: 15 additions & 11 deletions dist/CptvPlayerVue.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_

/***/ }),

/***/ 1740:
/***/ 8242:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
Expand Down Expand Up @@ -760,7 +760,7 @@ if (typeof window !== 'undefined') {
// Indicate to webpack that this file can be concatenated
/* harmony default export */ const setPublicPath = (null);

;// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"b2ba098c-vue-loader-template"}!./node_modules/vue-loader-v15/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js??ruleSet[0].rules[0].use[0]!./node_modules/vue-loader-v15/lib/index.js??vue-loader-options!./src/CptvPlayer.vue?vue&type=template&id=2ecd0be0&
;// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"b2ba098c-vue-loader-template"}!./node_modules/vue-loader-v15/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js??ruleSet[0].rules[0].use[0]!./node_modules/vue-loader-v15/lib/index.js??vue-loader-options!./src/CptvPlayer.vue?vue&type=template&id=f769d71a&
var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{class:['cptv-player', { 'stand-alone': _vm.standAlone }]},[_c('div',{key:"container",ref:"container",staticClass:"video-container"},[_c('canvas',{key:"base",ref:"canvas",class:['video-canvas', { smoothed: _vm.smoothed }]}),_c('canvas',{key:"overlay",ref:"overlayCanvas",staticClass:"overlay-canvas"}),_c('span',{key:"messaging",class:['player-messaging', { show: _vm.playerMessage !== null }],domProps:{"innerHTML":_vm._s(_vm.playerMessage)}}),_c('span',{directives:[{name:"show",rawName:"v-show",value:(_vm.showValueInfo),expression:"showValueInfo"}],key:"px-value",ref:"valueTooltip",staticClass:"value-tooltip"},[_vm._v(_vm._s(_vm.valueUnderCursor)+" ")]),(_vm.openUserDefinedCptvFile)?_c('div',{key:"openUserFile",staticClass:"playback-controls show"},[_c('b-form-file',{staticClass:"cptv-drop-area",attrs:{"accept":".cptv","state":_vm.userSuppliedFile !== null,"placeholder":"Choose a CPTV file or drop one here...","drop-placeholder":"Drop file here..."},model:{value:(_vm.userSuppliedFile),callback:function ($$v) {_vm.userSuppliedFile=$$v},expression:"userSuppliedFile"}})],1):_vm._e(),_c('div',{key:"buffering",class:[
'playback-controls',
{ show: _vm.isBuffering && !_vm.openUserDefinedCptvFile } ]},[_c('font-awesome-icon',{staticClass:"fa-spin buffering",attrs:{"icon":"spinner","size":"4x"}})],1),_c('div',{key:"playback-controls",class:[
Expand Down Expand Up @@ -13440,7 +13440,7 @@ var CptvPlayerComponent = /*#__PURE__*/function (_Vue) {
switch (_context2.prev = _context2.next) {
case 0:
if (this.totalFrames) {
_context2.next = 12;
_context2.next = 13;
break;
}

Expand All @@ -13455,19 +13455,20 @@ var CptvPlayerComponent = /*#__PURE__*/function (_Vue) {
break;
}

return _context2.abrupt("break", 12);
return _context2.abrupt("break", 13);

case 6:
CptvPlayervue_type_script_lang_ts_frames.push(frame);
_context2.next = 9;
this.loadedFrames = CptvPlayervue_type_script_lang_ts_frames.length;
_context2.next = 10;
return cptvDecoder.getTotalFrames();

case 9:
case 10:
this.totalFrames = _context2.sent;
_context2.next = 0;
break;

case 12:
case 13:
case "end":
return _context2.stop();
}
Expand Down Expand Up @@ -13623,7 +13624,8 @@ var CptvPlayerComponent = /*#__PURE__*/function (_Vue) {
}, {
key: "firstFrameForTrack",
value: function firstFrameForTrack(trackIndex) {
var frameForTrack = Object.entries(this.processedTracks).find(function (_ref4) {
var frameForTrack = Object.entries(this.processedTracks // eslint-disable-next-line @typescript-eslint/no-unused-vars
).find(function (_ref4) {
var _ref5 = _slicedToArray(_ref4, 2),
_ = _ref5[0],
tracks = _ref5[1];
Expand All @@ -13635,7 +13637,8 @@ var CptvPlayerComponent = /*#__PURE__*/function (_Vue) {
}, {
key: "onPastLastFrameForTrack",
value: function onPastLastFrameForTrack(trackIndex) {
var entries = Object.entries(this.processedTracks);
var entries = Object.entries(this.processedTracks); // eslint-disable-next-line @typescript-eslint/no-unused-vars

var firstFrameForTrackIndex = entries.findIndex(function (_ref6) {
var _ref7 = _slicedToArray(_ref6, 2),
_ = _ref7[0],
Expand All @@ -13644,7 +13647,8 @@ var CptvPlayerComponent = /*#__PURE__*/function (_Vue) {
return Object.keys(tracks).map(Number).includes(trackIndex);
});
var fromStartOfTrack = entries.slice(firstFrameForTrackIndex);
var onePastLastFrameForTrackIndex = fromStartOfTrack.findIndex(function (_ref8) {
var onePastLastFrameForTrackIndex = fromStartOfTrack.findIndex( // eslint-disable-next-line @typescript-eslint/no-unused-vars
function (_ref8) {
var _ref9 = _slicedToArray(_ref8, 2),
_ = _ref9[0],
tracks = _ref9[1];
Expand Down Expand Up @@ -25514,7 +25518,7 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__3507__;
/******/ // startup
/******/ // Load entry module and return exports
/******/ // This entry module doesn't tell about it's top-level declarations so it can't be inlined
/******/ var __webpack_exports__ = __webpack_require__(1740);
/******/ var __webpack_exports__ = __webpack_require__(8242);
/******/ __webpack_exports__ = __webpack_exports__.default;
/******/
/******/ return __webpack_exports__;
Expand Down
2 changes: 1 addition & 1 deletion dist/CptvPlayerVue.umd.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/CptvPlayerVue.umd.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/CptvPlayerVue.umd.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cptv-player-vue",
"version": "1.0.3",
"version": "1.0.4",
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build --target lib --name CptvPlayerVue ./src/CptvPlayer.vue",
Expand Down
10 changes: 7 additions & 3 deletions src/CptvPlayer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,7 @@ export default class CptvPlayerComponent extends Vue {
break;
}
frames.push(frame);
this.loadedFrames = frames.length;
this.totalFrames = await cptvDecoder.getTotalFrames();
}
}
Expand Down Expand Up @@ -798,18 +799,21 @@ export default class CptvPlayerComponent extends Vue {
firstFrameForTrack(trackIndex: number): number {
const frameForTrack = Object.entries(
this.processedTracks
// eslint-disable-next-line @typescript-eslint/no-unused-vars
).find(([_, tracks]) =>
Object.keys(tracks).map(Number).includes(trackIndex)
);
return (frameForTrack && Number(frameForTrack[0])) || 0;
}
onPastLastFrameForTrack(trackIndex: number): number {
const entries = Object.entries(this.processedTracks);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const firstFrameForTrackIndex = entries.findIndex(([_, tracks]) =>
Object.keys(tracks).map(Number).includes(trackIndex)
);
const fromStartOfTrack = entries.slice(firstFrameForTrackIndex);
let onePastLastFrameForTrackIndex = fromStartOfTrack.findIndex(
// eslint-disable-next-line @typescript-eslint/no-unused-vars
([_, tracks]) => !Object.keys(tracks).map(Number).includes(trackIndex)
);
if (onePastLastFrameForTrackIndex === -1) {
Expand Down Expand Up @@ -1341,7 +1345,7 @@ export default class CptvPlayerComponent extends Vue {
}
}
}
setLabelFontStyle(overlayContext: CanvasRenderingContext2D) {
setLabelFontStyle(overlayContext: CanvasRenderingContext2D): void {
overlayContext.font = "13px sans-serif";
overlayContext.lineWidth = 4;
overlayContext.strokeStyle = "rgba(0, 0, 0, 0.5)";
Expand All @@ -1350,7 +1354,7 @@ export default class CptvPlayerComponent extends Vue {
drawBottomLeftOverlayLabel(
label: string | false,
overlayContext: CanvasRenderingContext2D
) {
): void {
if (label) {
this.setLabelFontStyle(overlayContext);
const bottomPadding = 10;
Expand All @@ -1372,7 +1376,7 @@ export default class CptvPlayerComponent extends Vue {
drawBottomRightOverlayLabel(
label: string | false,
overlayContext: CanvasRenderingContext2D
) {
): void {
if (label) {
this.setLabelFontStyle(overlayContext);
const bottomPadding = 10;
Expand Down

0 comments on commit c84f1ee

Please sign in to comment.