Skip to content

Instantly share code, notes, and snippets.

@michelmelo
Forked from nomaad/gist:3283201
Created August 22, 2013 20:45
Show Gist options
  • Save michelmelo/6312566 to your computer and use it in GitHub Desktop.
Save michelmelo/6312566 to your computer and use it in GitHub Desktop.
// load sound from remote url
Ti.API.log(item.value.value1); // While the crash occurs, this contains 'http://stadtfestradio.argovia.ch/live'
var streamer = Ti.Media.createAudioPlayer({url:item.value.value1, bufferSize: 4096});
var isPlaying = false;
var container = Ti.UI.createView(api.combine($$.ContentChildView, {top:topMargin}));
parent.add(container);
var stack = Ti.UI.createView({
left: 65,
layout: 'vertical',
width:Ti.UI.SIZE,
height:Ti.UI.SIZE
});
container.add(stack);
var title = Titanium.UI.createLabel(
api.combine(
$$.ContentTitleLabel,
{
text:item.value.value2,
height:Ti.UI.SIZE
}));
stack.add(title);
var text = Titanium.UI.createLabel(
api.combine(
$$.ContentTextLabel,
{
text:item.value.value3,
height:Ti.UI.SIZE
}));
stack.add(text);
var playButton = Ti.UI.createImageView(
api.combine($$.ContentPlayButtonImage,
{
left: 0,
image:'/core/images/icon_play.png'
}));
playButton.addEventListener('click', function()
{
if(isPlaying){
isPlaying = false;
streamer.stop();
playButton.image = '/core/images/icon_play.png'
}
else{
isPlaying = true;
streamer.start();
playButton.image = '/core/images/icon_pause.png'
}
});
container.add(playButton);
resume();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment