简体   繁体   English

VLCJ 获取视频时间

[英]VLCJ Get Video Time

I have the following code and i want to get the time of my Video but it returns -1.我有以下代码,我想获取视频的时间,但它返回 -1。 Anyone know why?有谁知道为什么?

long video= ourMediaPlayer.getMediaPlayer().getLength();

I have tried with getTime() instead of getLength but it returns -1.我尝试过使用 getTime() 而不是 getLength 但它返回 -1。

Thanks for your help.感谢您的帮助。

get current video time获取当前视频时间

embeddedMediaPlayer.status().time();

get video duration获取视频时长

embeddedMediaPlayer.status().length();

get current video position获取当前视频位置

embeddedMediaPlayer.status().position()

note:my vlcj version is 4.4.4注意:我的 vlcj 版本是 4.4.4

The getLength() method returns -1 if the length is unknown.如果长度未知,则getLength()方法返回 -1。 It depends on the type of media, but sometimes the length is not known until some time after the media starts playing.这取决于媒体的类型,但有时直到媒体开始播放一段时间后才知道长度。

Similarly, getTime() returns -1 for the time (number of milliseconds from the start of the media) if the time is not known - ie if the media has not started playing yet.类似地,如果时间未知,即如果媒体尚未开始播放,则getTime()返回 -1 表示时间(从媒体开始的毫秒数)。

This is simply how the underlying native library works, and therefore how vlcj works also.这就是底层原生库的工作方式,因此 vlcj 也是如此。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM