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. Perihal Kloteran Battery Gum Plu

RR,

Berkaitan dengan kloteran Battery Gum Plus yang delay dikarenakan stock dari
pabriknya yang memang kosong, saya ingin memberitahukan bahwa barangnya baru
dikirimkan dari Taiwan pada tanggal 28 April 2010, perkiraan sampai di
Jakarta sekitar tanggal 2-3 Mei 2010.

Sebagai kompensasi dari keterlambatan ini, harga saya revisi menjadi *Rp
525.000,- *sudah termasuk ongkos kirim ke seluruh Indonesia.
Kompensasi ini juga dikarenakan harga yang diturunkan dari pihak
distributor, dan juga karena nilai dollar terhadap rupiah juga turun.

Bagi rekan2 yang sudah membayar full, silakan japri saya nomor rekeningnya
untuk pengembalian sisanya.
Terima kasih atas perhatian dan kesabarannya menunggu.

*************
Deska Affif
088-1100-GAYA (4292) | Y!: GadgetGaya
www.gadgetgaya.com  |  Light Up Your Gadget!

-- 
"Indonesian Android Community [id-android]" 

2. Sudah diralat, WTS: Motorola Titanium XT800 Heading To South Korea [Cheap Android Phone To Have 3.7-Inch Display, HDMI Out, 600MHz Processor]

Terima kasih bro,

Sudah saya ralat tadi pagi, subject:

Re: Ralat WTI, Motorola Titanium XT800 Heading To South Korea [Cheap
Android Phone To Have 3.7-Inch Display, HDMI Out, 600MHz Processor]



Salam Android,

AH





-- 
"Indonesian Android Community [id-android]" 

3. mo tanya tentang bootloader.

4. First impressions on Droid

5. gimana ya cara hapus SuperUser WhiteList?

6. Steps to transfer a simple object from server to android using XML

7. navigation for nexus