我在Videogular2的一个angular项目中,我在检索视频时长时遇到了问题。
Vgapi具有duration属性。
duration只读:number返回以秒为单位的持续时间。
当我使用它的时候。它返回Nan。
当我查看源代码时:
* Returns the duration in seconds of the current media resource. A NaN value is returned if duration is not available, or Infinity if the media resource is streaming.
*/
readonly duration: number;
/**视频是mp4格式的。已填写持续时间文件元标记(1:00分钟)
我会尝试ogg和webm表单,看看它是否能胜任工作。
也许有人有过使用videogular2的经验?
感谢所有人:)
发布于 2019-03-14 18:02:31
onPlayerReady(api:VgAPI)
{
this.api = api;
this.api.getDefaultMedia().subscriptions.ended.subscribe(
($event) => { this.router.navigate(['home'])
});
this.api.getDefaultMedia().subscriptions.loadedMetadata.subscribe(
($event) => {
this.duration=this.api.duration;
console.log("API "+this.api.duration);
});
}加载元数据时,您可以获得持续时间。
https://stackoverflow.com/questions/55158242
复制相似问题