[android-developers] Re: MediaPlayer setDataSource or prepare issue

2008-12-19 Thread Dave Sparks

setDataSource() with offset is for playing an embedded media file. In
other words, there must be a valid WAVE header at the specified
offset. An example use case is a resource file that contains many WAVE
files with a table of contents at the beginning.

You can call seekTo() to start playback at time offset.

On Dec 19, 8:28 am, Kenneth Loafman  wrote:
> This code segment:
>
>
>
> >path = "/data/noise.wav";
> >file = new File(path);
>
> >tx.setText("Prepping audio...");
> >Log.i(TAG, "Prepping audio");
>
> >for (int i = 0; i < nPlay; ++i) {
> >myPlayers[i] = new MediaPlayer();
> >   randFile[i] = new RandomAccessFile(file, "r");
> >myPlayers[i].setAudioStreamType(AudioManager.STREAM_MUSIC);
> >   myPlayers[i].setDataSource(randFile[i].getFD(),
> >i * segSize,
> >segSize);
> >Log.i(TAG, "Prepping: " + i);
> >   myPlayers[i].prepare();
> >}
>
> produces this log:
>
>
>
> >12-19 10:05:38.369: INFO/SilentSpeech(3427): Prepping audio
> >12-19 10:05:38.409: INFO/SilentSpeech(3427): Prepping: 0
> >12-19 10:05:38.449: INFO/SilentSpeech(3427): Prepping: 1
> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): error: Prepare failed.: 
> >status=0xFFFC
> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): java.io.IOException: Prepare 
> >failed.: status=0xFFFC
> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at 
> >android.media.MediaPlayer.prepare(Native Method)
> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at 
> >com.android.silentspeech.SSActivity.playAudio(SSActivity.java:55)
> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at 
> >com.android.silentspeech.SSActivity.onCreate(SSActivity.java:38)
> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at 
> >android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1122)
> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at 
> >android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2103)
> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at 
> >android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2156)
> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at 
> >android.app.ActivityThread.access$1800(ActivityThread.java:112)
> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at 
> >android.app.ActivityThread$H.handleMessage(ActivityThread.java:1580)
> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at 
> >android.os.Handler.dispatchMessage(Handler.java:88)
> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at 
> >android.os.Looper.loop(Looper.java:123)
> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at 
> >android.app.ActivityThread.main(ActivityThread.java:3742)
> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at 
> >java.lang.reflect.Method.invokeNative(Native Method)
> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at 
> >java.lang.reflect.Method.invoke(Method.java:515)
> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at 
> >com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at 
> >com.android.internal.os.ZygoteInit.main(ZygoteInit.java:497)
> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at 
> >dalvik.system.NativeStart.main(Native Method)
>
> If I replace "i * segSize" with "0" to always start at the front, it
> works.  Strange.
>
> Does this mean that:
> 1) setDataSource() does not work with offset? -or-
> 2) do I need to put a file header at each offset?
>
> If the answer is 2, is there an option to take raw input?
>
> ...Thanks,
> ...Ken
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: MediaPlayer setDataSource or prepare issue

2008-12-19 Thread Dave Sparks

As a workaround, you can use seekTo followed by start to start
playback partly into a file, and then call getCurrentPosition
repeatedly until you get to the point where you want to stop and then
call stop or pause. It's not going to be very precise.

On Dec 19, 12:27 pm, Dave Sparks  wrote:
> No there is no way to play a segment of a media file.
>
> On Dec 19, 9:52 am, Kenneth Loafman  wrote:
>
> > Is there a way to set the length of the segment to play like
> > setDataSource() has?  I'm not seeing it.
>
> > ...Thanks,
> > ...Ken
>
> > On Fri, 19 Dec 2008 09:03:30 -0800 (PST), Dave Sparks
>
> >  wrote:
>
> > >setDataSource() with offset is for playing an embedded media file. In
> > >other words, there must be a valid WAVE header at the specified
> > >offset. An example use case is a resource file that contains many WAVE
> > >files with a table of contents at the beginning.
>
> > >You can call seekTo() to start playback at time offset.
>
> > >On Dec 19, 8:28 am, Kenneth Loafman  wrote:
> > >> This code segment:
>
> > >> >path = "/data/noise.wav";
> > >> >file = new File(path);
>
> > >> >tx.setText("Prepping audio...");
> > >> >Log.i(TAG, "Prepping audio");
>
> > >> >for (int i = 0; i < nPlay; ++i) {
> > >> >myPlayers[i] = new MediaPlayer();
> > >> >   randFile[i] = new RandomAccessFile(file, "r");
> > >> >myPlayers[i].setAudioStreamType(AudioManager.STREAM_MUSIC);
> > >> >   myPlayers[i].setDataSource(randFile[i].getFD(),
> > >> >i * segSize,
> > >> >segSize);
> > >> >Log.i(TAG, "Prepping: " + i);
> > >> >   myPlayers[i].prepare();
> > >> >}
>
> > >> produces this log:
>
> > >> >12-19 10:05:38.369: INFO/SilentSpeech(3427): Prepping audio
> > >> >12-19 10:05:38.409: INFO/SilentSpeech(3427): Prepping: 0
> > >> >12-19 10:05:38.449: INFO/SilentSpeech(3427): Prepping: 1
> > >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): error: Prepare failed.: 
> > >> >status=0xFFFC
> > >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): java.io.IOException: 
> > >> >Prepare failed.: status=0xFFFC
> > >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at 
> > >> >android.media.MediaPlayer.prepare(Native Method)
> > >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at 
> > >> >com.android.silentspeech.SSActivity.playAudio(SSActivity.java:55)
> > >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at 
> > >> >com.android.silentspeech.SSActivity.onCreate(SSActivity.java:38)
> > >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at 
> > >> >android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1122)
> > >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at 
> > >> >android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2103)
> > >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at 
> > >> >android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2156)
> > >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at 
> > >> >android.app.ActivityThread.access$1800(ActivityThread.java:112)
> > >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at 
> > >> >android.app.ActivityThread$H.handleMessage(ActivityThread.java:1580)
> > >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at 
> > >> >android.os.Handler.dispatchMessage(Handler.java:88)
> > >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at 
> > >> >android.os.Looper.loop(Looper.java:123)
> > >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at 
> > >> >android.app.ActivityThread.main(ActivityThread.java:3742)
> > >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at 
> > >> >java.lang.reflect.Method.invokeNative(Native Method)
> > >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at 
> > >> >java.lang.reflect.Method.invoke(Method.java:515)
> > >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at 
> > >> >com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
> > >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at 
> > >> >com.android.internal.os.ZygoteInit.main(ZygoteInit.java:497)
> > >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at 
> > >> >dalvik.system.NativeStart.main(Native Method)
>
> > >> If I replace "i * segSize" with "0" to always start at the front, it
> > >> works.  Strange.
>
> > >> Does this mean that:
> > >> 1) setDataSource() does not work with offset? -or-
> > >> 2) do I need to put a file header at each offset?
>
> > >> If the answer is 2, is there an option to take raw input?
>
> > >> ...Thanks,
> > >> ...Ken
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit thi

[android-developers] Re: MediaPlayer setDataSource or prepare issue

2008-12-19 Thread Dave Sparks

No there is no way to play a segment of a media file.

On Dec 19, 9:52 am, Kenneth Loafman  wrote:
> Is there a way to set the length of the segment to play like
> setDataSource() has?  I'm not seeing it.
>
> ...Thanks,
> ...Ken
>
> On Fri, 19 Dec 2008 09:03:30 -0800 (PST), Dave Sparks
>
>  wrote:
>
> >setDataSource() with offset is for playing an embedded media file. In
> >other words, there must be a valid WAVE header at the specified
> >offset. An example use case is a resource file that contains many WAVE
> >files with a table of contents at the beginning.
>
> >You can call seekTo() to start playback at time offset.
>
> >On Dec 19, 8:28 am, Kenneth Loafman  wrote:
> >> This code segment:
>
> >> >path = "/data/noise.wav";
> >> >file = new File(path);
>
> >> >tx.setText("Prepping audio...");
> >> >Log.i(TAG, "Prepping audio");
>
> >> >for (int i = 0; i < nPlay; ++i) {
> >> >myPlayers[i] = new MediaPlayer();
> >> >   randFile[i] = new RandomAccessFile(file, "r");
> >> >myPlayers[i].setAudioStreamType(AudioManager.STREAM_MUSIC);
> >> >   myPlayers[i].setDataSource(randFile[i].getFD(),
> >> >i * segSize,
> >> >segSize);
> >> >Log.i(TAG, "Prepping: " + i);
> >> >   myPlayers[i].prepare();
> >> >}
>
> >> produces this log:
>
> >> >12-19 10:05:38.369: INFO/SilentSpeech(3427): Prepping audio
> >> >12-19 10:05:38.409: INFO/SilentSpeech(3427): Prepping: 0
> >> >12-19 10:05:38.449: INFO/SilentSpeech(3427): Prepping: 1
> >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): error: Prepare failed.: 
> >> >status=0xFFFC
> >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): java.io.IOException: 
> >> >Prepare failed.: status=0xFFFC
> >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at 
> >> >android.media.MediaPlayer.prepare(Native Method)
> >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at 
> >> >com.android.silentspeech.SSActivity.playAudio(SSActivity.java:55)
> >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at 
> >> >com.android.silentspeech.SSActivity.onCreate(SSActivity.java:38)
> >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at 
> >> >android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1122)
> >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at 
> >> >android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2103)
> >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at 
> >> >android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2156)
> >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at 
> >> >android.app.ActivityThread.access$1800(ActivityThread.java:112)
> >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at 
> >> >android.app.ActivityThread$H.handleMessage(ActivityThread.java:1580)
> >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at 
> >> >android.os.Handler.dispatchMessage(Handler.java:88)
> >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at 
> >> >android.os.Looper.loop(Looper.java:123)
> >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at 
> >> >android.app.ActivityThread.main(ActivityThread.java:3742)
> >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at 
> >> >java.lang.reflect.Method.invokeNative(Native Method)
> >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at 
> >> >java.lang.reflect.Method.invoke(Method.java:515)
> >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at 
> >> >com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
> >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at 
> >> >com.android.internal.os.ZygoteInit.main(ZygoteInit.java:497)
> >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at 
> >> >dalvik.system.NativeStart.main(Native Method)
>
> >> If I replace "i * segSize" with "0" to always start at the front, it
> >> works.  Strange.
>
> >> Does this mean that:
> >> 1) setDataSource() does not work with offset? -or-
> >> 2) do I need to put a file header at each offset?
>
> >> If the answer is 2, is there an option to take raw input?
>
> >> ...Thanks,
> >> ...Ken
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: MediaPlayer setDataSource or prepare issue

2008-12-19 Thread Xavier Mathews

Yea you could do it that way but its not going to stop where you want
it unless you use a b repeate.

On 12/19/2008, Dave Sparks  wrote:
>
> As a workaround, you can use seekTo followed by start to start
> playback partly into a file, and then call getCurrentPosition
> repeatedly until you get to the point where you want to stop and then
> call stop or pause. It's not going to be very precise.
>
> On Dec 19, 12:27 pm, Dave Sparks  wrote:
>> No there is no way to play a segment of a media file.
>>
>> On Dec 19, 9:52 am, Kenneth Loafman  wrote:
>>
>> > Is there a way to set the length of the segment to play like
>> > setDataSource() has?  I'm not seeing it.
>>
>> > ...Thanks,
>> > ...Ken
>>
>> > On Fri, 19 Dec 2008 09:03:30 -0800 (PST), Dave Sparks
>>
>> >  wrote:
>>
>> > >setDataSource() with offset is for playing an embedded media file. In
>> > >other words, there must be a valid WAVE header at the specified
>> > >offset. An example use case is a resource file that contains many WAVE
>> > >files with a table of contents at the beginning.
>>
>> > >You can call seekTo() to start playback at time offset.
>>
>> > >On Dec 19, 8:28 am, Kenneth Loafman  wrote:
>> > >> This code segment:
>>
>> > >> >path = "/data/noise.wav";
>> > >> >file = new File(path);
>>
>> > >> >tx.setText("Prepping audio...");
>> > >> >Log.i(TAG, "Prepping audio");
>>
>> > >> >for (int i = 0; i < nPlay; ++i) {
>> > >> >myPlayers[i] = new MediaPlayer();
>> > >> >   randFile[i] = new RandomAccessFile(file, "r");
>> > >> >
>> > >> > myPlayers[i].setAudioStreamType(AudioManager.STREAM_MUSIC);
>> > >> >   myPlayers[i].setDataSource(randFile[i].getFD(),
>> > >> >i * segSize,
>> > >> >segSize);
>> > >> >Log.i(TAG, "Prepping: " + i);
>> > >> >   myPlayers[i].prepare();
>> > >> >}
>>
>> > >> produces this log:
>>
>> > >> >12-19 10:05:38.369: INFO/SilentSpeech(3427): Prepping audio
>> > >> >12-19 10:05:38.409: INFO/SilentSpeech(3427): Prepping: 0
>> > >> >12-19 10:05:38.449: INFO/SilentSpeech(3427): Prepping: 1
>> > >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): error: Prepare
>> > >> > failed.: status=0xFFFC
>> > >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): java.io.IOException:
>> > >> > Prepare failed.: status=0xFFFC
>> > >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at
>> > >> > android.media.MediaPlayer.prepare(Native Method)
>> > >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at
>> > >> > com.android.silentspeech.SSActivity.playAudio(SSActivity.java:55)
>> > >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at
>> > >> > com.android.silentspeech.SSActivity.onCreate(SSActivity.java:38)
>> > >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at
>> > >> > android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1122)
>> > >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at
>> > >> > android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2103)
>> > >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at
>> > >> > android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2156)
>> > >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at
>> > >> > android.app.ActivityThread.access$1800(ActivityThread.java:112)
>> > >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at
>> > >> > android.app.ActivityThread$H.handleMessage(ActivityThread.java:1580)
>> > >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at
>> > >> > android.os.Handler.dispatchMessage(Handler.java:88)
>> > >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at
>> > >> > android.os.Looper.loop(Looper.java:123)
>> > >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at
>> > >> > android.app.ActivityThread.main(ActivityThread.java:3742)
>> > >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at
>> > >> > java.lang.reflect.Method.invokeNative(Native Method)
>> > >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at
>> > >> > java.lang.reflect.Method.invoke(Method.java:515)
>> > >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at
>> > >> > com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
>> > >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at
>> > >> > com.android.internal.os.ZygoteInit.main(ZygoteInit.java:497)
>> > >> >12-19 10:05:38.469: ERROR/SilentSpeech(3427): at
>> > >> > dalvik.system.NativeStart.main(Native Method)
>>
>> > >> If I replace "i * segSize" with "0" to always start at the front, it
>> > >> works.  Strange.
>>
>> > >> Does this mean that:
>> > >> 1) setDataSource() does not work with offset? -or-
>> > >> 2) do I need to put a file header at each offset?
>>
>> > >> If the answer is 2, is there an option to take raw input?
>>
>> > >> ...Thanks,
>> > >> ...Ken
> >
>


-- 
Xavier A. Mathews
Student/Browser Specialist/Developer/Web-Master
Client Based Tech Support Spe