mengzhidaren/Vlc-sdk-lib

getDuration()返回的长度是0,seekTo()没法使用,iOS的vlc可以使用,虽然返回的时长都是0,这个能支持一下吗

zijin2014 opened this issue · 1 comments

getDuration()返回的长度是0,seekTo()没法使用,iOS的vlc可以使用,虽然返回的时长都是0,这个能支持一下吗

在VlcPlayer这个类中onEventNative方法的case MediaPlayer.Event.TimeChanged:的时候可以获取到
` String t = event.getTimeChanged() + "";
只是需要吧获取到的时间长度格式化已下

/**
 * 将长度转换为时间
 *
 * @param timeMs
 * @return
 */

public static String stringForTime(int timeMs) {  //18565
    StringBuilder mFormatBuilder = new StringBuilder();
    Formatter mFormatter = new Formatter(mFormatBuilder, Locale.getDefault());
    int totalSeconds = timeMs / 1000;
    int seconds = totalSeconds % 60;
    int minutes = (totalSeconds / 60) % 60;
    int hours = totalSeconds / 3600;
    mFormatBuilder.setLength(0);
    if (hours > 0) {
        return mFormatter.format("%d:%02d:%02d", hours, minutes, seconds).toString();
    } else {
        return mFormatter.format("%02d:%02d", minutes, seconds).toString();
    }





}

`