Assume that the current time is now 7000 milliseconds. When the time is 3000--6000, the value of 3000 is taken. When 6000--9000, the value of 6000 is taken, that is, the maximum value in xml that is less than the current time is taken.
xml file,
Copy the code code as follows:
<?xml version="1.0" encoding="utf-8"?>
<catalog>
<cd>
<ID>2</ID>
<title>Lecture 1</title>
<mediaUrl>123</mediaUrl>
<htmlUrl>1.html</htmlUrl>
<orderNo>2</orderNo>
<StudyTimes>00:00:30</StudyTimes>
<Secondss times="30000">1.html</Secondss>
</cd>
<cd>
<ID>3</ID>
<title>Lecture 2</title>
<mediaUrl>123</mediaUrl>
<htmlUrl>2.html</htmlUrl>
<orderNo>2</orderNo>
<StudyTimes>00:01:00</StudyTimes>
<Secondss times="60000">2.html</Secondss>
</cd>
<cd>
<ID>4</ID>
<title>Lecture 3</title>
<mediaUrl>123</mediaUrl>
<htmlUrl>3.html</htmlUrl>
<orderNo>2</orderNo>
<StudyTimes>00:01:30</StudyTimes>
<Secondss times="90000">3.html</Secondss>
</cd>
</catalog>
javascript:
MediaPlayer.Controls.CurrentPosition * 1000 is the current time
Copy the code code as follows:
function times() {
//Define array array
var array =new Array();
//Define xmldom protocol
var xmlDom =new ActiveXObject("Microsoft.XMLDOM");
xmlDom.async =false;
//Load xml file
xmlDom.load(id.value +"_imsmanifest.xml"); //Jump
try {
//Find all Secondss
x = xmlDom.getElementsByTagName("Secondss");
//Traverse
for (i =0; i < x.length; i++) {
//Get the times attribute
var s = x[i].getAttribute("times");
//If the attribute value is less than MediaPlayer.Controls.CurrentPosition * 1000, add it to the array
if (s <= MediaPlayer.Controls.CurrentPosition *1000) {
array.push(s);
}
}
//Sort the array. At this time, array[array.length - 1] is less than the maximum value in MediaPlayer.Controls.CurrentPosition * 1000
array.sort();
}