Titanium:如何在开始播放之前检查音频流是否存在?

时间:2013-08-06 20:54:24

标签: ios titanium audio-streaming audio-player

我正在构建一个在线广播流媒体应用程序,到目前为止它在Android和ios上流式传输和播放音频。但是当我开始在ios设备(iphone)上测试我的应用程序时,我发现了一个错误。

“文件错误 - 无法配置网络读取流”

当网络重置并且我从锁定模式恢复iphone并尝试从暂停模式恢复audioPlayer时,会发生这种情况。音频播放器播放缓冲区中剩余的内容并弹出错误。有没有办法检查音频流是否存在?

我还发现如果将暂停按钮操作更改为“audioPlayer.stop()”和“start()”,则不会发生此错误。这是我的暂停\恢复按钮代码

pauseResumeButton.addEventListener('click', function() {

if(Ti.Network.online) {
    if (Ti.App.player.paused) {

    // I need a condition here to check if audio stream exists before start player.

            pauseResumeButton.backgroundImage="/images/pause.png";          
            Ti.App.player.start();      
    }
    else { 
        pauseResumeButton.backgroundImage="/images/play.png";
        Ti.App.player.pause();  
    }
}
else {
   Ti.UI.createAlertDialog({
        message: 'Network Offline',
        title: 'Error',
        ok:'Ok'
     }).show(); 
}
});

0 个答案:

没有答案
相关问题