Unexplained error from MediaPlayer

All your problems with Audio, Video and Images.

Unexplained error from MediaPlayer

Postby Sir^Knigget » Sun Feb 21, 2010 2:32 pm

My code tries to play an MP3 file from res/raw.

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. FileDescriptor fd = appContext.getResources().openRawResourceFd(R.raw.ringtone)
  2.  
  3.                                         .getFileDescriptor();
  4.  
  5. player = new MediaPlayer();
  6.  
  7.                         try
  8.  
  9.                         {
  10.  
  11.                                 player.setAudioStreamType(AudioManager.STREAM_RING);
  12.  
  13.                                 player.setDataSource(fd);
  14.  
  15.                                 player.prepare();                      
  16.  
  17.                         }
  18.  
  19.                         catch (IllegalArgumentException e)
  20.  
  21.                         {
  22.  
  23.                                 // TODO Auto-generated catch block
  24.  
  25.                                 e.printStackTrace();
  26.  
  27.                                 player = null;
  28.  
  29.                                 return;
  30.  
  31.                         }
  32.  
  33.                         catch (IllegalStateException e)
  34.  
  35.                         {
  36.  
  37.                                 // TODO Auto-generated catch block
  38.  
  39.                                 e.printStackTrace();
  40.  
  41.                                 player = null;
  42.  
  43.                                 return;
  44.  
  45.                         }
  46.  
  47.                         catch (IOException e)
  48.  
  49.                         {
  50.  
  51.                                 // TODO Auto-generated catch block
  52.  
  53.                                 e.printStackTrace();
  54.  
  55.                                 player = null;
  56.  
  57.                                 return;
  58.  
  59.                         }
  60.  
  61.  
  62.  
  63.                         player.setLooping(true);
  64.  
  65.                         player.start();
  66.  
  67.  
Parsed in 0.032 seconds, using GeSHi 1.0.8.4

The log shows:

02-21 15:18:18.360: ERROR/PlayerDriver(51): Command PLAYER_SET_DATA_SOURCE completed with an error or info PVMFErrNotSupported
02-21 15:18:18.380: ERROR/MediaPlayer(693): error (1, -4)
02-21 15:18:18.390: WARN/PlayerDriver(51): PVMFInfoErrorHandlingComplete

After player.prepare() is called.

I really don't have a hint.
I won't use MediaPlayer.create() because I need player.setAudioStreamType(AudioManager.STREAM_RING);

Would appreciate any help on this...
Sir^Knigget
Freshman
Freshman
 
Posts: 9
Joined: Wed Sep 30, 2009 6:00 pm

Top

Postby mrco » Tue Feb 23, 2010 2:07 pm

R.raw.ringtone is it mp3?
Try to use setDataSource(FileDescriptor, long, long) method ( http://developer.android.com/reference/ ... %20long%29 ).
mrco
Experienced Developer
Experienced Developer
 
Posts: 71
Joined: Fri Jan 15, 2010 11:31 am
Location: 2V Software

Postby srujanak » Wed Mar 10, 2010 10:59 am

Hi,
I'm using setDataSource("http://somesite//music.ogg"); to play an online .ogg file.
Doesn't work. :(
I tried the same with an mp3 file,and it works. I can play .ogg files from my sdcard and from a resource file.

But with .ogg stream, it says
Media Player Service error -2
Media Player Unable to create media player

the error is - setDataSource failed. status=0x80000000 and an IOException is thrown.

the error -2 corresponds to ERROR_OPEN_FAILED. :shock:
I'm currently looking into the android source code to figure out the exact flow of operations.Any ideas as to why an ogg stream can't be accessed and how to solve this problem?

Thanks in advance :)
Srujana
srujanak
Freshman
Freshman
 
Posts: 3
Joined: Thu Jan 21, 2010 8:57 am

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 7 guests