How see on display minute and second CurrentTime <video> in html5 if use jquery?

微笑、不失礼 提交于 2019-12-04 16:52:27

You need to convert the currentTime to a String to perform .split() and .substr() on it, e.g.

var time = id.get(0).currentTime;
var minutes = time.toString().split('.')[0];   
var seconds = time.toString().split('.')[1].substr('0','1'); 

To convert them back to a float (Number) for use with numerical functions do like so:

minutes = parseFloat(minutes);

See http://jsfiddle.net/NpgD5/23/ for a working example (click on the video to get the time).

EDIT: currentTime returns the time in seconds so your minnow variable is actually seconds and secnow are milliseconds, a better way of getting minutes and seconds from currentTime is:

var time = id.get(0).currentTime;
var minutes = Math.floor(time / 60);   
var seconds = Math.floor(time); 

You can Code like that:

var id = $('#main_video_player');
var idn = 'VideoBar_wrap';

alert(id.get(0).currentTime); //worked i see '12.324543356'

var minnow=String(id.get(0).currentTime).split('.')[0];   
alert(minnow);

var secnow=String(String(id.get(0).currentTime).split('.')[1]).substr(0,1);   
alert(secnow);

You have to convert currentTime value to String object

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!