Created
August 7, 2012 08:28
-
-
Save nomaad/3283201 to your computer and use it in GitHub Desktop.
Titanium Audio Streaming crashes app on 3G connection(Android)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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