【问题标题】:Videogular2 Get video duration return NaNVideogular2 获取视频时长返回 NaN
【发布时间】:2019-08-05 02:17:22
【问题描述】:

我正在使用 Videogular2 进行 Angular 项目,但在检索视频时长时遇到了问题。

Vgapi 有一个持续时间属性。

持续时间 [只读]​​ :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 有经验吗?

谢谢大家:)

【问题讨论】:

    标签: angular videogular


    【解决方案1】:
    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);
      });
    }
    

    加载元数据后,您可以获得持续时间。

    【讨论】:

      猜你喜欢
      • 2015-07-25
      • 2019-03-01
      • 1970-01-01
      • 2016-04-09
      • 2015-05-30
      • 2016-11-02
      • 2017-10-10
      • 1970-01-01
      相关资源
      最近更新 更多