MediaPlayer & seek on startup

by David Given » Thu, 27 Nov 2008 06:56:22 GMT


Sponsored Links
 I'm trying to play streaming music. The user has previously requested
that the stream start a certain way into the stream. How do I do this?

What I'm finding is that if I do:

mediaplayer.setDataSource(...);
mediaplayer.prepare();
mediaplayer.seekTo(...);

...then the seek happens *after* the initial buffer is read, which of
course is a waste [*]. But if I do:

mediaplayer.setDataSource(...);
mediaplayer.seekTo(...);
mediaplayer.prepare();

...then of course I get an IllegalStateException because the MediaPlayer
hasn't been prepared yet!

Has anyone managed to make anything like this work?



[*] Actually, of course, I'm using prepareAsync(). In fact, what I'm
observing is that calling seekTo() from the onPrepared() callback tends
to confuse MediaPlayer and it hands me a -38 error and I have to reset
and start again. It seems to only want to seek after the playback has
had a chance to settle for a few moments.

-- 
€€  €€€€€  http://www.cowlark.com  €€€€€
,S3=T)=T+/(Vquot;),(Vquot;M),(V,)quot;(V,V)quot;)'
--- Conway's Game Of Life, in one line of APL



MediaPlayer & seek on startup

by Dave Sparks » Thu, 27 Nov 2008 08:13:33 GMT


 You must always call prepare() before seekTo(). The player engine
needs to read the first part of the stream to identify the stream type
and required codecs and read the content index (if it exists).



--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


MediaPlayer & seek on startup

by David Given » Thu, 27 Nov 2008 22:30:09 GMT


 


Well, yes, I'm aware of that. However, it doesn't just read the stream
header, it spends 10-15 seconds buffering the initial stream. This is
leading to a really poor user experience, as the user has to wait (and
pay) for the first part of the stream to be buffered --- then the seek
happens, it all gets thrown away, and the user has to wait (and pay) for
*another* 10-15 seconds while the buffer gets filled from the correct
location.

Is there any way of streamlining this? Can I tell MediaPlayer to *just*
read the metadata and not to try and fill the buffer, for example?

-- 
David Given
[EMAIL PROTECTED]

--~--~---------~--~----~------------~-------~--~----~



MediaPlayer & seek on startup

by David Given » Sat, 29 Nov 2008 05:23:04 GMT


 

[...]

Does anyone have any suggestions on how do this? If I can't make this
work, my app is basically stuffed, and nothing I've tried is working.

Brief summary: I need to be able to tell MediaPlayer to start playing
from somewhere in the middle of the stream, not the start. If I call
seekTo() after prepare() then the user has to wait for the buffer to be
filled twice, which can take up to thirty seconds, and they're not going
to put up with that.

Is there a way to tell it to prepare the stream (reading the stream
header, etc) but *not* to fill the buffer until I tell it to start
playing? That would work.

-- 
€€  €€€€€  http://www.cowlark.com  €€€€€
,S3=T)=T+/(Vquot;),(Vquot;M),(V,)quot;(V,V)quot;)'
--- Conway's Game Of Life, in one line of APL



MediaPlayer & seek on startup

by Dave Sparks » Tue, 02 Dec 2008 01:14:41 GMT


 I can't think of any alternative solution at this time. The code that
handles this is in the OpenCore engine and not something you can
address with a Java API.

Perhaps this is something we can address in a future release.





--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Encoding

Hi,

When I parse data from a http request sometimes the  sign and others
do not get encoded correctly and result in the SAX parser complaining

What's the default encoding?

Thanks
--~--~---------~--~----~------------~-------~--~----~

2. help with apn settings insertion

hi ppl...
im getting permission error when trying to insert into apn
setting table(carriers)
ContentResolver contentResolver = getContentResolver();
        contentResolver.insert(Uri.parse("content://telephony/carriers"),
cv);
im using sdk 1.5 ... kindly help!!
thanks in advance!

--~--~---------~--~----~------------~-------~--~----~

3. how to do a HttpDelete properly

4. : Hands on Technical Training on Linux Device Drive

5. How could I run a Uri based Intent in a Tab Page?

6. autoLink text from app widget

7. How do you display many points on a map?