java.io.IOException: Prepare failed.: status=0x1

Appcelerator JIRA | Paul Dowsett | 5 years ago
  1. 0

    As per [this Q&A question|http://developer.appcelerator.com/question/121172/aacp-shoutcast-radio-stream], AAC streams don't work on Android 2.1, and rarely work on 2.2, when using Titanium 1.7.X. See the notes next to the URLs in the following code for more info. Note that code allows each stream to be tested in sequence. {code:lang=javascript} var url = []; url.push("http://st2.webradioworld.net:8036"); // direct stream - exception on 2.1, exception on 2.2 url.push("http://radio.musicvictim.com:8012"); // direct stream - exception on 2.1, works on 2.2 // Info page: http://www.radioparadise.com/content.php?name=Listen url.push("http://www.radioparadise.com/musiclinks/rp_64aac.m3u"); // exception on 2.1, exception on 2.2 url.push("http://173.244.214.174:8008"); // direct stream - exception on 2.1, exception on 2.2 // Info page: http://kzsulive.stanford.edu/ url.push("http://kzsulive.stanford.edu/audio/kzsu-1-48.pls"); // exception on 2.1, exception on 2.2 url.push("http://171.66.118.51/kzsu-1-48.aac"); // direct stream - exception on 2.1, does not work on 2.2 but no exception var win = Ti.UI.createWindow({ backgroundColor : "white", layout:'vertical', exitOnClose:true }); Ti.Media.audioSessionMode = Ti.Media.AUDIO_SESSION_MODE_AMBIENT; var urlIndex = 0; var audio = Ti.Media.createAudioPlayer({ url:url[urlIndex], preload:false, allowBackground:true }); audio.format = Ti.Media.AUDIO_FORMAT_AAC; audio.audioSessionMode = Ti.Media.AUDIO_SESSION_MODE_PLAYBACK; var buttonControl = Ti.UI.createButton({ title: 'Play', isSound:false, top:50 }); win.add(buttonControl); win.open(); var nav_hidden = false; Ti.API.info("Starting stream: "+ url[urlIndex]); buttonControl.addEventListener('click', function(){ if(buttonControl.isSound){ audio.stop(); buttonControl.title = 'Play'; buttonControl.isSound = !buttonControl.isSound; Ti.API.info("Stream stopped"); if(urlIndex === url.length-1){ urlIndex = 0; } else { urlIndex++; } audio.url = url[urlIndex]; } else { Ti.API.info("Starting stream: "+ audio.url); audio.start(); buttonControl.title = 'Stop'; buttonControl.isSound = !buttonControl.isSound; Ti.API.info("Stream started"); } }); audio.addEventListener('change', function(e){ Ti.API.info("Current audio state: " + e.state); }); {code} The following shows output generated using Android 2.2 when the first and second streams were played, the first caused an exception, the next played successfully. {code} 628 TiAPI I (kroll$1: app://app.js) [2568,5385] Starting stream: http://st2.webradioworld.net:8036 34 StagefrightPlayer I setDataSource('http://st2.webradioworld.net:8036') 118 dalvikvm D GC_EXPLICIT freed 144 objects / 7536 bytes in 132ms 628 MediaPlayer E error (1, -2147483648) 628 TiSound W (kroll$1: app://app.js) [1381,6766] Issue while initializing : 628 TiSound W java.io.IOException: Prepare failed.: status=0x1 628 TiSound W at android.media.MediaPlayer.prepare(Native Method) 628 TiSound W at ti.modules.titanium.media.TiSound.initialize(TiSound.java:118) 628 TiSound W at ti.modules.titanium.media.TiSound.play(TiSound.java:177) 628 TiSound W at ti.modules.titanium.media.AudioPlayerProxy.play(AudioPlayerProxy.java:111) 628 TiSound W at ti.modules.titanium.media.AudioPlayerProxy.start(AudioPlayerProxy.java:104) 628 TiSound W at ti.modules.titanium.media.AudioPlayerProxyBindingGen$9.invoke(AudioPlayerProxyBindingGen.java:355) 628 TiSound W at org.appcelerator.kroll.KrollMethod.call(KrollMethod.java:51) 628 TiSound W at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1701) 628 TiSound W at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:854) 628 TiSound W at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:164) 628 TiSound W at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:426) 628 TiSound W at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3177) 628 TiSound W at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:162) 628 TiSound W at org.appcelerator.titanium.kroll.KrollCallback.callSync(KrollCallback.java:139) 628 TiSound W at org.appcelerator.titanium.kroll.KrollCallback$1.run(KrollCallback.java:164) 628 TiSound W at android.os.Handler.handleCallback(Handler.java:587) 628 TiSound W at android.os.Handler.dispatchMessage(Handler.java:92) 628 TiSound W at android.os.Looper.loop(Looper.java:123) 628 TiSound W at org.appcelerator.titanium.kroll.KrollHandlerThread.run(KrollHandlerThread.java:86) 628 TiAPI I (kroll$1: app://app.js) [57,6823] Stream started 628 TiAPI I (kroll$1: app://app.js) [6,6829] Current audio state: 4 628 TiAPI I (kroll$1: app://app.js) [24,6853] Current audio state: 5 628 TiAPI I (kroll$1: app://app.js) [34684,41537] Stream stopped 161 EventLogService I Aggregate from 1309717206104 (log), 1309717206104 (data) 161 dalvikvm D GC_FOR_MALLOC freed 4070 objects / 443448 bytes in 94ms 628 TiAPI I (kroll$1: app://app.js) [4457,45994] Starting stream: http://radio.musicvictim.com:8012 34 StagefrightPlayer I setDataSource('http://radio.musicvictim.com:8012') 34 AwesomePlayer I calling prefetcher->prepare() 34 Prefetcher I [0x782b8] cache below low water mark, filling cache. 34 AwesomePlayer I prefetcher is done preparing 34 AudioSink D bufferCount (4) is too small and increased to 12 628 TiAPI I (kroll$1: app://app.js) [1950,47944] Stream started 628 TiAPI I (kroll$1: app://app.js) [2,47946] Current audio state: 4 628 TiAPI I (kroll$1: app://app.js) [28,47974] Current audio state: 1 628 TiAPI I (kroll$1: app://app.js) [29,48003] Current audio state: 3 628 TiAPI I (kroll$1: app://app.js) [16,48019] Current audio state: 3 34 AudioFlinger W write blocked for 74 msecs, 2573 delayed writes, thread 0xb3f0 34 AwesomePlayer E Not sending buffering status because duration is unknown. 34 AudioFlinger W write blocked for 73 msecs, 2600 delayed writes, thread 0xb3f0 34 AudioFlinger W write blocked for 72 msecs, 2629 delayed writes, thread 0xb3f0 34 AudioFlinger W write blocked for 72 msecs, 2654 delayed writes, thread 0xb3f0 34 AudioFlinger W write blocked for 75 msecs, 2678 delayed writes, thread 0xb3f0 {code}

    Appcelerator JIRA | 5 years ago | Paul Dowsett
    java.io.IOException: Prepare failed.: status=0x1
  2. 0

    As per [this Q&A question|http://developer.appcelerator.com/question/121172/aacp-shoutcast-radio-stream], AAC streams don't work on Android 2.1, and rarely work on 2.2, when using Titanium 1.7.X. See the notes next to the URLs in the following code for more info. Note that code allows each stream to be tested in sequence. {code:lang=javascript} var url = []; url.push("http://st2.webradioworld.net:8036"); // direct stream - exception on 2.1, exception on 2.2 url.push("http://radio.musicvictim.com:8012"); // direct stream - exception on 2.1, works on 2.2 // Info page: http://www.radioparadise.com/content.php?name=Listen url.push("http://www.radioparadise.com/musiclinks/rp_64aac.m3u"); // exception on 2.1, exception on 2.2 url.push("http://173.244.214.174:8008"); // direct stream - exception on 2.1, exception on 2.2 // Info page: http://kzsulive.stanford.edu/ url.push("http://kzsulive.stanford.edu/audio/kzsu-1-48.pls"); // exception on 2.1, exception on 2.2 url.push("http://171.66.118.51/kzsu-1-48.aac"); // direct stream - exception on 2.1, does not work on 2.2 but no exception var win = Ti.UI.createWindow({ backgroundColor : "white", layout:'vertical', exitOnClose:true }); Ti.Media.audioSessionMode = Ti.Media.AUDIO_SESSION_MODE_AMBIENT; var urlIndex = 0; var audio = Ti.Media.createAudioPlayer({ url:url[urlIndex], preload:false, allowBackground:true }); audio.format = Ti.Media.AUDIO_FORMAT_AAC; audio.audioSessionMode = Ti.Media.AUDIO_SESSION_MODE_PLAYBACK; var buttonControl = Ti.UI.createButton({ title: 'Play', isSound:false, top:50 }); win.add(buttonControl); win.open(); var nav_hidden = false; Ti.API.info("Starting stream: "+ url[urlIndex]); buttonControl.addEventListener('click', function(){ if(buttonControl.isSound){ audio.stop(); buttonControl.title = 'Play'; buttonControl.isSound = !buttonControl.isSound; Ti.API.info("Stream stopped"); if(urlIndex === url.length-1){ urlIndex = 0; } else { urlIndex++; } audio.url = url[urlIndex]; } else { Ti.API.info("Starting stream: "+ audio.url); audio.start(); buttonControl.title = 'Stop'; buttonControl.isSound = !buttonControl.isSound; Ti.API.info("Stream started"); } }); audio.addEventListener('change', function(e){ Ti.API.info("Current audio state: " + e.state); }); {code} The following shows output generated using Android 2.2 when the first and second streams were played, the first caused an exception, the next played successfully. {code} 628 TiAPI I (kroll$1: app://app.js) [2568,5385] Starting stream: http://st2.webradioworld.net:8036 34 StagefrightPlayer I setDataSource('http://st2.webradioworld.net:8036') 118 dalvikvm D GC_EXPLICIT freed 144 objects / 7536 bytes in 132ms 628 MediaPlayer E error (1, -2147483648) 628 TiSound W (kroll$1: app://app.js) [1381,6766] Issue while initializing : 628 TiSound W java.io.IOException: Prepare failed.: status=0x1 628 TiSound W at android.media.MediaPlayer.prepare(Native Method) 628 TiSound W at ti.modules.titanium.media.TiSound.initialize(TiSound.java:118) 628 TiSound W at ti.modules.titanium.media.TiSound.play(TiSound.java:177) 628 TiSound W at ti.modules.titanium.media.AudioPlayerProxy.play(AudioPlayerProxy.java:111) 628 TiSound W at ti.modules.titanium.media.AudioPlayerProxy.start(AudioPlayerProxy.java:104) 628 TiSound W at ti.modules.titanium.media.AudioPlayerProxyBindingGen$9.invoke(AudioPlayerProxyBindingGen.java:355) 628 TiSound W at org.appcelerator.kroll.KrollMethod.call(KrollMethod.java:51) 628 TiSound W at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1701) 628 TiSound W at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:854) 628 TiSound W at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:164) 628 TiSound W at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:426) 628 TiSound W at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3177) 628 TiSound W at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:162) 628 TiSound W at org.appcelerator.titanium.kroll.KrollCallback.callSync(KrollCallback.java:139) 628 TiSound W at org.appcelerator.titanium.kroll.KrollCallback$1.run(KrollCallback.java:164) 628 TiSound W at android.os.Handler.handleCallback(Handler.java:587) 628 TiSound W at android.os.Handler.dispatchMessage(Handler.java:92) 628 TiSound W at android.os.Looper.loop(Looper.java:123) 628 TiSound W at org.appcelerator.titanium.kroll.KrollHandlerThread.run(KrollHandlerThread.java:86) 628 TiAPI I (kroll$1: app://app.js) [57,6823] Stream started 628 TiAPI I (kroll$1: app://app.js) [6,6829] Current audio state: 4 628 TiAPI I (kroll$1: app://app.js) [24,6853] Current audio state: 5 628 TiAPI I (kroll$1: app://app.js) [34684,41537] Stream stopped 161 EventLogService I Aggregate from 1309717206104 (log), 1309717206104 (data) 161 dalvikvm D GC_FOR_MALLOC freed 4070 objects / 443448 bytes in 94ms 628 TiAPI I (kroll$1: app://app.js) [4457,45994] Starting stream: http://radio.musicvictim.com:8012 34 StagefrightPlayer I setDataSource('http://radio.musicvictim.com:8012') 34 AwesomePlayer I calling prefetcher->prepare() 34 Prefetcher I [0x782b8] cache below low water mark, filling cache. 34 AwesomePlayer I prefetcher is done preparing 34 AudioSink D bufferCount (4) is too small and increased to 12 628 TiAPI I (kroll$1: app://app.js) [1950,47944] Stream started 628 TiAPI I (kroll$1: app://app.js) [2,47946] Current audio state: 4 628 TiAPI I (kroll$1: app://app.js) [28,47974] Current audio state: 1 628 TiAPI I (kroll$1: app://app.js) [29,48003] Current audio state: 3 628 TiAPI I (kroll$1: app://app.js) [16,48019] Current audio state: 3 34 AudioFlinger W write blocked for 74 msecs, 2573 delayed writes, thread 0xb3f0 34 AwesomePlayer E Not sending buffering status because duration is unknown. 34 AudioFlinger W write blocked for 73 msecs, 2600 delayed writes, thread 0xb3f0 34 AudioFlinger W write blocked for 72 msecs, 2629 delayed writes, thread 0xb3f0 34 AudioFlinger W write blocked for 72 msecs, 2654 delayed writes, thread 0xb3f0 34 AudioFlinger W write blocked for 75 msecs, 2678 delayed writes, thread 0xb3f0 {code}

    Appcelerator JIRA | 5 years ago | Paul Dowsett
    java.io.IOException: Prepare failed.: status=0x1
  3. 0

    MediaPlayer: Prepare failed status 0x1 error while streaming song

    Stack Overflow | 3 years ago | Bersh
    java.io.IOException: Prepare failed.: status=0x1
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Accessing internally stored media files - MediaPlayer on Android

    Stack Overflow | 3 years ago | Sriram
    java.io.IOException: Prepare failed.: status=0x1
  6. 0

    Android MediaPlayer - error (1, -4) when playing a song

    Stack Overflow | 3 years ago | Hanady
    java.io.IOException: Prepare failed.: status=0x1
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.io.IOException

    Prepare failed.: status=0x1

    at android.media.MediaPlayer.prepare()
  2. Android Platform
    MediaPlayer.prepare
    1. android.media.MediaPlayer.prepare(Native Method)
    1 frame
  3. ti.modules.titanium
    AudioPlayerProxyBindingGen$9.invoke
    1. ti.modules.titanium.media.TiSound.initialize(TiSound.java:118)
    2. ti.modules.titanium.media.TiSound.play(TiSound.java:177)
    3. ti.modules.titanium.media.AudioPlayerProxy.play(AudioPlayerProxy.java:111)
    4. ti.modules.titanium.media.AudioPlayerProxy.start(AudioPlayerProxy.java:104)
    5. ti.modules.titanium.media.AudioPlayerProxyBindingGen$9.invoke(AudioPlayerProxyBindingGen.java:355)
    5 frames
  4. org.appcelerator.kroll
    KrollMethod.call
    1. org.appcelerator.kroll.KrollMethod.call(KrollMethod.java:51)
    1 frame
  5. Rhino
    InterpretedFunction.call
    1. org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1701)
    2. org.mozilla.javascript.Interpreter.interpret(Interpreter.java:854)
    3. org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:164)
    4. org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:426)
    5. org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3177)
    6. org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:162)
    6 frames
  6. org.appcelerator.titanium
    KrollCallback$1.run
    1. org.appcelerator.titanium.kroll.KrollCallback.callSync(KrollCallback.java:139)
    2. org.appcelerator.titanium.kroll.KrollCallback$1.run(KrollCallback.java:164)
    2 frames
  7. Android Platform
    Looper.loop
    1. android.os.Handler.handleCallback(Handler.java:587)
    2. android.os.Handler.dispatchMessage(Handler.java:92)
    3. android.os.Looper.loop(Looper.java:123)
    3 frames
  8. org.appcelerator.titanium
    KrollHandlerThread.run
    1. org.appcelerator.titanium.kroll.KrollHandlerThread.run(KrollHandlerThread.java:86)
    1 frame