MediaPlayer streaming on droid

All your problems with Audio, Video and Images.

MediaPlayer streaming on droid

Postby ueberbill » Mon Jul 05, 2010 5:11 pm

I can get mediaplayer to prepare to stream a file from a URL datasource (and eventually play it when a play button is clicked) on my cliq (android 1.5), and on emulators running 1.6, 2.0. and 2.1. When a tester using a droid (2.1, I believe) tries to do the same thing (call prepare() on the mediaplayer aftrer the datasource is set), the mediaplayer's own logcat entries indicate that some buffering is happening but then this line:
07-02 15:00:35.957: ERROR/PlayerDriver(987): Command (6) was cancelled

and then no more buffering. The onPrepared event never gets fired, either. The only other reference I've seen to this error on forums says that the file must be downloaded to the phone for Droids (and possibly Nexus One's) and THEN played. Is that really true? Can anyone else call prepare() (or prepareAsync) on a mediaplayer with a url datasource and have it work for their droid or nexus one?

Thanks
ueberbill
Junior Developer
Junior Developer
 
Posts: 20
Joined: Tue Apr 13, 2010 7:23 pm

Top

Re: MediaPlayer streaming on droid

Postby anarche » Tue Jul 06, 2010 1:58 am

Droid certainly can (or at least the Milestone version), as long as its a supported filetype.

Can you post full logcat?
anarche
Master Developer
Master Developer
 
Posts: 369
Joined: Sun Apr 11, 2010 5:21 am

Re: MediaPlayer streaming on droid

Postby ueberbill » Tue Jul 06, 2010 1:45 pm

Here's what I'm doing (slightly edited, MediaPlayer-only stuff included):
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. player.setDataSource(url);  //This URL is to an mp3 file
  2. player.setAudioStreamType(AudioManager.STREAM_MUSIC);
  3. player.setOnPreparedListener(new OnPreparedListener() {
  4.                                
  5.                                 public void onPrepared(MediaPlayer mp) {
  6.                                         Message m = Message.obtain(mHandler);
  7.                                         m.what=CLIENT_AUDIO_DOWNLOADED;
  8.                                         mHandler.sendMessage(m);
  9.                                        
  10.                                 }
  11.                         });
  12.  player.prepare();
  13.  
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


And here's what logcat says:
07-04 15:58:12.630: INFO/WT(14843): Adding click listener to play button
07-04 15:58:12.630: INFO/WT(14843): Adding click listener to stop button
07-04 15:58:13.958: INFO/PlayerDriver(987): buffering (1)
07-04 15:58:24.052: INFO/PlayerDriver(987): buffering (63)
07-04 15:58:24.552: DEBUG/dalvikvm(14763): GC freed 1544 objects / 84736 bytes in 63ms
07-04 15:58:24.716: DEBUG/dalvikvm(14763): GC freed 1857 objects / 97728 bytes in 45ms
07-04 15:58:24.880: DEBUG/dalvikvm(1017): GC freed 30722 objects / 1531400 bytes in 160ms
07-04 15:58:39.513: DEBUG/dalvikvm(14763): GC freed 1544 objects / 84704 bytes in 56ms
07-04 15:58:39.677: DEBUG/dalvikvm(14763): GC freed 1857 objects / 97928 bytes in 43ms
07-04 15:58:40.615: DEBUG/AlarmManagerService(1017): Kernel timezone updated to 300 minutes west of GMT
07-04 15:58:47.997: DEBUG/dalvikvm(14763): GC freed 230 objects / 12384 bytes in 98ms
07-04 15:58:54.529: DEBUG/dalvikvm(14763): GC freed 1336 objects / 73336 bytes in 59ms
07-04 15:58:54.693: DEBUG/dalvikvm(14763): GC freed 1838 objects / 96856 bytes in 42ms
07-04 15:59:02.099: ERROR/PlayerDriver(987): Command (6) was cancelled
ueberbill
Junior Developer
Junior Developer
 
Posts: 20
Joined: Tue Apr 13, 2010 7:23 pm

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 17 guests