Problem:
AudioPlayer does not play streaming media over the Internet.
{quote}
This works fine on url / files but not on streams like SHOUTcast
http://www.shoutcast.com
I have never gotten the onload / onerror event fired on a XMLHttpRequest
Customer
wants to avoid -> File Error: _"Unable to configure network read stream"_
{quote}
var audio_stream = Titanium.Media.createAudioPlayer();
var playing = false;
var now_playing_data_timer = undefined;
var tabGroup = Ti.UI.createTabGroup();
var win = Titanium.UI.createWindow({
title:'Listen',
backgroundColor:'#000'
});
var tab = Titanium.UI.createTab({
icon:'KS_nav_views.png',
title:'Listen',
window:win
});
var text = Titanium.UI.createLabel({
color:'blue',
text:'Song:',
width:'auto',
top: 0,
left:0
});
var imageview = Titanium.UI.createImageView({
image:"http://2.bp.blogspot.com/_ZqpzRV9D624/TNnn-FLSgmI/AAAAAAAAAAs/8ca4flYJKhg/S350/logo%2Bde%2Bmusica%2B1.png",
height:100,
width:110,
top:150,
backgroundColor:'white'
});
var play_button = Titanium.UI.createButton({
image: "playbutton.png",
width: 110,
height: 80,
top: 10,
title:"Play",
color: "red"
});
var play_stream = function(stream_url){
playing = true;
audio_stream.setUrl(stream_url);
audio_stream.start();
};
var stop_stream = function(){
playing = false;
audio_stream.stop();
};
win.addEventListener('open', function(e) {
init();
});
var init = function() {
win.add(text);
win.add(play_button);
win.add(imageview);
};
play_button.addEventListener('click',function()
{
var xhr = Ti.Network.createHTTPClient();
var stream_url = 'http://yp.shoutcast.com/sbin/tunein-station.pls?id=1268400';
xhr.onload = function(e) {
playing = true;
audio_stream.setUrl(stream_url);
audio_stream.start();
};
xhr.onerror = function(e) {
alert(e.error);
};
xhr.setTimeout(10000);
xhr.open('GET', stream_url);
xhr.file = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory,'tunein-station.pls');
xhr.send();
});
tabGroup.addTab(tab);
tabGroup.open();
Associated Helpdesk Ticket
http://support.appcelerator.com/tickets/APP-577977
The url in the sample code does not contain a stream. Instead, it is a text file, not sound. It is the end developer's responsibility to parse the text file, find urls in it that actually _are_ of streams, and then pass a stream url to audioPlayer.
same issue, can be fixed?
Closing ticket as invalid.