-
Notifications
You must be signed in to change notification settings - Fork 358
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
67 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,4 @@ | ||
import { createApp } from 'vue' | ||
import App from './App.vue' | ||
|
||
const loadScript = (url) => | ||
new Promise((resolve, reject) => { | ||
const script = document.createElement('script') | ||
script.src = url | ||
script.onload = () => { | ||
resolve() | ||
} | ||
script.onerror = () => { | ||
reject('cannot load script ' + url) | ||
} | ||
document.body.appendChild(script) | ||
}) | ||
|
||
loadScript('/dist/missile-v20220421.js').then((res) => createApp(App).mount('#app')) | ||
createApp(App).mount('#app') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,56 @@ | ||
import H265webjsModule from "../../public/dist/index"; | ||
import H265webjsModule from '../../public/dist/index' | ||
|
||
const durationFormmat = (val) => { | ||
val = val.toString(); | ||
if (val.length < 2) return "0" + val; | ||
return val; | ||
}; | ||
val = val.toString() | ||
if (val.length < 2) return '0' + val | ||
return val | ||
} | ||
|
||
const setDurationText = (duration) => { | ||
if (duration < 0) return "Player"; | ||
const randDuration = Math.round(duration); | ||
if (duration < 0) return 'Player' | ||
const randDuration = Math.round(duration) | ||
return ( | ||
durationFormmat(Math.floor(randDuration / 3600)) + | ||
":" + | ||
':' + | ||
durationFormmat(Math.floor((randDuration % 3600) / 60)) + | ||
":" + | ||
':' + | ||
durationFormmat(Math.floor(randDuration % 60)) | ||
); | ||
}; | ||
) | ||
} | ||
|
||
export const createPlayerServer = (videoUrl, config) => { | ||
return H265webjsModule.createPlayer(videoUrl, config); | ||
}; | ||
return H265webjsModule.createPlayer(videoUrl, config) | ||
} | ||
|
||
export const executePlayerServer = (player, timelineEl) => { | ||
// todo.... | ||
let mediaInfo = null; | ||
let mediaInfo = null | ||
player.onLoadFinish = () => { | ||
mediaInfo = player.mediaInfo(); | ||
if (mediaInfo.videoType === "vod") { | ||
mediaInfo = player.mediaInfo() | ||
if (mediaInfo.videoType === 'vod') { | ||
timelineEl.textContent = | ||
setDurationText(0) + | ||
"/" + | ||
setDurationText(mediaInfo.meta.durationMs / 1000); | ||
'/' + | ||
setDurationText(mediaInfo.meta.durationMs / 1000) | ||
} | ||
}; | ||
} | ||
player.onPlayTime = (pts) => { | ||
if (mediaInfo.videoType === "vod") { | ||
if (mediaInfo.videoType === 'vod') { | ||
timelineEl.textContent = | ||
setDurationText(pts) + | ||
"/" + | ||
setDurationText(mediaInfo.meta.durationMs / 1000); | ||
'/' + | ||
setDurationText(mediaInfo.meta.durationMs / 1000) | ||
} | ||
}; | ||
player.do(); | ||
}; | ||
} | ||
player.do() | ||
} | ||
|
||
/** | ||
* | ||
* @param {ReturnType<typeof H265webjsModule.createPlayer>} playerInstance | ||
*/ | ||
export const destoryPlayerServer = (playerInstance) => { | ||
// release playerInstance & forece Gc | ||
playerInstance.release() | ||
playerInstance = null | ||
} |