我正在追加视频数据:
Html: <div id="videoData"></div>
追加后的HTML:
<div id="videoData">
<video width="75%" style="max-width: 60em;" autoplay="" controls="" class="center-block" id="video">
<source type="video/mp4" src="http://amerytech.net/lc_production/uploads/course_videos/Probability/Probability1.mp4" style="max-width: 60em;"></source>
<source type="video/ogg" src="http://amerytech.net/lc_production/uploads/course_videos/Probability/Probability1.mp4"></source>
Probability1.mp4
</video>
</div>
$.ajax({
url: "check_result.php",
method: "POST",
// async: false,
data: {
'action': 'playVideoCheck',
'course_id': course_id,
'videoId' : videoId
},
dataType: "json",
success: function (response) {
if (response["success"] == true) {
$("#success_message").show();
$("#success_message").html(response["message"]);
var path = response["videoPath"];
$("#videoData").append('<video id="video" width="75%" class="center-block" controls autoplay style="max-width: 60em;"><source style="max-width: 60em;" src="' + path + '" type="video/mp4"/><source src="' + path + '" type="video/ogg"/>' + response["videoName"] + '</video>');
}
}
});
在我尝试获取未播放的总时间后附加视频后, 但是当我发出两个警报时,它会好起来的。所以问题是我想在完全追加之后得到视频时间我该怎么做..?
$(document).ajaxStop(function () {
var video = document.querySelector('video');
if (video) {
//alert ("coming"); //when commented affecting bottom
alert (video.duration); //when commented top line it is not working
} else {
alert ("not coming");
}
});