Skip to content

Instantly share code, notes, and snippets.

@imlucas
Created September 25, 2009 00:46
Show Gist options
  • Select an option

  • Save imlucas/193179 to your computer and use it in GitHub Desktop.

Select an option

Save imlucas/193179 to your computer and use it in GitHub Desktop.
/**
* Play a song from Amie Street
*/
var songId = '2ajVBbF1YOUx';
var url = 'http://amiestreet.com/stream/song/'+songId+'.mp3';
var sound = Titanium.Media.createSound(url);
var listenerId = sound.addEventListener('complete', function() {
sound.removeEventListener('complete', listenerId);
var dlg = Titanium.UI.createAlertDialog({
'title' : 'Sound Complete',
'message' : 'sound completed',
'buttonNames' : [ 'OK' ]
});
dlg.show();
});
sound.play();
/**
* Results in the following exception:
E/TiSnd ( 758): (WebViewCoreThread) Error setting file descriptor:
E/TiSnd ( 758): java.io.FileNotFoundException: Resources/http://amiestreet.com/stream/song/2ajVBbF1YOUx.mp3
E/TiSnd ( 758): at android.content.res.AssetManager.openAssetFd(Native Method)
E/TiSnd ( 758): at android.content.res.AssetManager.openFd(AssetManager.java:316)
E/TiSnd ( 758): at org.appcelerator.titanium.module.media.TitaniumSound.initialize(TitaniumSound.java:80)
E/TiSnd ( 758): at org.appcelerator.titanium.module.media.TitaniumSound.play(TitaniumSound.java:152)
E/TiSnd ( 758): at android.webkit.LoadListener.nativeFinished(Native Method)
E/TiSnd ( 758): at android.webkit.LoadListener.nativeFinished(Native Method)
E/TiSnd ( 758): at android.webkit.LoadListener.tearDown(LoadListener.java:1018)
E/TiSnd ( 758): at android.webkit.LoadListener.handleEndData(LoadListener.java:624)
E/TiSnd ( 758): at android.webkit.LoadListener.handleMessage(LoadListener.java:195)
E/TiSnd ( 758): at android.os.Handler.dispatchMessage(Handler.java:99)
E/TiSnd ( 758): at android.os.Looper.loop(Looper.java:123)
E/TiSnd ( 758): at android.webkit.WebViewCore$WebCoreThread.run(WebViewCore.java:462)
E/TiSnd ( 758): at java.lang.Thread.run(Thread.java:1058)
E/MediaPlayer( 758): prepareAsync called in state 1
W/TiSnd ( 758): (WebViewCoreThread) Issue while initializing :
W/TiSnd ( 758): java.lang.IllegalStateException
W/TiSnd ( 758): at android.media.MediaPlayer.prepare(Native Method)
W/TiSnd ( 758): at org.appcelerator.titanium.module.media.TitaniumSound.initialize(TitaniumSound.java:99)
W/TiSnd ( 758): at org.appcelerator.titanium.module.media.TitaniumSound.play(TitaniumSound.java:152)
W/TiSnd ( 758): at android.webkit.LoadListener.nativeFinished(Native Method)
W/TiSnd ( 758): at android.webkit.LoadListener.nativeFinished(Native Method)
W/TiSnd ( 758): at android.webkit.LoadListener.tearDown(LoadListener.java:1018)
W/TiSnd ( 758): at android.webkit.LoadListener.handleEndData(LoadListener.java:624)
W/TiSnd ( 758): at android.webkit.LoadListener.handleMessage(LoadListener.java:195)
W/TiSnd ( 758): at android.os.Handler.dispatchMessage(Handler.java:99)
W/TiSnd ( 758): at android.os.Looper.loop(Looper.java:123)
W/TiSnd ( 758): at android.webkit.WebViewCore$WebCoreThread.run(WebViewCore.java:462)
W/TiSnd ( 758): at java.lang.Thread.run(Thread.java:1058)
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment