【发布时间】:2015-12-12 22:13:56
【问题描述】:
var player = Titanium.Media.createAudioPlayer({
url : '101.mp3',
allowBackground : false
});
var eventHandler = function(e) {
Ti.API.info("Handler:" + JSON.stringify(e, null, 4));
};
Ti.API.info("Setting up event handlers");
player.addEventListener('progress', eventHandler);
// player.addEventListener('change', eventHandler);
Ti.API.info("Starting player...");
player.play();
结果是:
[INFO] : Setting up event handlers
[INFO] : Starting player...
[INFO] : Handler:{
[INFO] : "progress": 927.4149659863946,
[INFO] : "bubbles": true,
[INFO] : "type": "progress",
[INFO] : "source": {},
[INFO] : "cancelBubble": false
[INFO] : }
[INFO] : Handler:{
[INFO] : "progress": 1926.984126984127,
[INFO] : "bubbles": true,
[INFO] : "type": "progress",
[INFO] : "source": {},
[INFO] : "cancelBubble": false
[INFO] : }
[INFO] : Handler:{
[INFO] : "progress": 2924.9206349206347,
[INFO] : "bubbles": true,
[INFO] : "type": "progress",
[INFO] : "source": {},
[INFO] : "cancelBubble": false
[INFO] : }
[INFO] : Handler:{
[INFO] : "progress": 3926.7346938775513,
[INFO] : "bubbles": true,
[INFO] : "type": "progress",
[INFO] : "source": {},
[INFO] : "cancelBubble": false
[INFO] : }
所以,显然我得到了“进度”事件......
现在,如果我取消注释第二个 addEventListener 调用:
player.addEventListener('progress', eventHandler);
player.addEventListener('change', eventHandler);
我明白了:
[INFO] : Setting up event handlers
[INFO] : Starting player...
[INFO] : Handler:{
[INFO] : "state": 1,
[INFO] : "description": "starting",
[INFO] : "bubbles": true,
[INFO] : "type": "change",
[INFO] : "source": {},
[INFO] : "cancelBubble": false
[INFO] : }
[INFO] : Handler:{
[INFO] : "state": 2,
[INFO] : "description": "waiting_for_data",
[INFO] : "bubbles": true,
[INFO] : "type": "change",
[INFO] : "source": {},
[INFO] : "cancelBubble": false
[INFO] : }
[INFO] : Handler:{
[INFO] : "state": 3,
[INFO] : "description": "waiting_for_queue",
[INFO] : "bubbles": true,
[INFO] : "type": "change",
[INFO] : "source": {},
[INFO] : "cancelBubble": false
[INFO] : }
[INFO] : Handler:{
[INFO] : "state": 4,
[INFO] : "description": "playing",
[INFO] : "bubbles": true,
[INFO] : "type": "change",
[INFO] : "source": {},
[INFO] : "cancelBubble": false
[INFO] : }
没有更多的“进展”事件?
谁能解释一下?
【问题讨论】:
标签: javascript titanium titanium-mobile