假设现在当前时间为7000毫秒。当时间为3000--6000是去3000的值,当6000--9000时取6000的值,即取xml中小于当前时间的最大值
xml文件,
View Code
<?xml version="1.0" encoding="utf-8"?>
<catalog>
<cd>
<ID>2</ID>
<title>第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>第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>第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>
<catalog>
<cd>
<ID>2</ID>
<title>第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>第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>第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为当前时间
View Code
function times() {
//定义array数组
var array =new Array();
//定义xmldom协议
var xmlDom =new ActiveXObject("Microsoft.XMLDOM");
xmlDom.async =false;
//加载xml文件
xmlDom.load(id.value +"_imsmanifest.xml"); //跳转
try {
//找到所有的Secondss
x = xmlDom.getElementsByTagName("Secondss");
//遍历
for (i =0; i < x.length; i++) {
//取times属性
var s = x[i].getAttribute("times");
//如果属性值小于 MediaPlayer.Controls.CurrentPosition * 1000则添加到数组里
if (s <= MediaPlayer.Controls.CurrentPosition *1000) {
array.push(s);
}
}
//排序array此时array[array.length - 1]就是小于MediaPlayer.Controls.CurrentPosition * 1000里面的最大值
array.sort();
}
//定义array数组
var array =new Array();
//定义xmldom协议
var xmlDom =new ActiveXObject("Microsoft.XMLDOM");
xmlDom.async =false;
//加载xml文件
xmlDom.load(id.value +"_imsmanifest.xml"); //跳转
try {
//找到所有的Secondss
x = xmlDom.getElementsByTagName("Secondss");
//遍历
for (i =0; i < x.length; i++) {
//取times属性
var s = x[i].getAttribute("times");
//如果属性值小于 MediaPlayer.Controls.CurrentPosition * 1000则添加到数组里
if (s <= MediaPlayer.Controls.CurrentPosition *1000) {
array.push(s);
}
}
//排序array此时array[array.length - 1]就是小于MediaPlayer.Controls.CurrentPosition * 1000里面的最大值
array.sort();
}