BxScript增加新功能,支持语音播放(mp3),扩展接口在全局对象Voice下,代码比较简洁且简单。
图一
图二
Win.create("BxScript", 800, 650, true, false, true);
Win.add([
{ type: "image", id: "img", title: "-", width: 800, height: 550, x: 0, y: 0, fontSize: "10", font: "微软雅黑" },
{ type: "label", id: "mp3Name", title: "未播放", width: 100, height: 30, x: 50, y: 560, fontSize: "10", font: "微软雅黑" },
{ type: "button", id: "nextBtn", title: "下一首", width: 100, height: 30, x: 350, y: 560, fontSize: "10", font: "微软雅黑" },
]);
var index = 1;
var base = "C:\\Users\\Administrator\\Desktop\\1\\"
var mp3list = ["38.6", "9420 - 麦小兜", "双截棍"]
Voice.open(base + mp3list[index] + ".mp3")
Win.mp3Name.setText("正在播放: " + mp3list[index])
Win.img.src(base + mp3list[index] + ".jpg")
Voice.play();
Win.nextBtn.onClick = function(){
if(index >= mp3list.length - 1){
index = 0;
} else {
index++;
}
Voice.close()
Voice.open(base + mp3list[index] + ".mp3")
Win.mp3Name.setText("正在播放: " + mp3list[index])
Win.img.src(base + mp3list[index] + ".jpg")
Voice.play();
}
Win.loop();