Hi David,

Regarding this mediaplayer access right thing, may you help take a
look at my issue?

I am writing an application which uses MediaPlayer to play video, but
I always encountered this issue:
java.io.IOException: Prepare failed.: status=0xFFFFFFFC

1. I tried to put the wmv file on sdcard or application folder, and
both are with same results.
2. I tried with the system's ringtone, e.g. /system/media/audio/
ringtones/BirdLoop.ogg, it can play the music.
3. i am using Android Debug Bridge version 1.0.20 on WinXP, with an
emulator

the code is here:
                File file = new File(filename);
                FileInputStream ins = new FileInputStream(file);
                mMediaPlayer.setDataSource(ins.getFD());
                mMediaPlayer.setDisplay(holder);
                mMediaPlayer.prepare();

It always throws an IOException in the "prepare()" method. If I
replace the file with that system's ringtone file, everything is ok.

Any suggestion? Really appreciate it.

Gery

On 11月14日, 下午4时20分, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> Due to the Android security model, MediaPlayer does not have root
> access rights. It can access the sdcard, but it can't access private
> app directories.
>
> Your app can explicitly grant MediaPlayer temporary access to secure
> files by opening the file and passing the file descriptor to
> MediaPlayer using the setDataSource(FileDescriptor fd) method.
>
> On Nov 4, 10:36 pm, pa018 <[EMAIL PROTECTED]> wrote:
>
>
>
> > Code first:
> >                 InputStream is = ;//some mixed audio
> >                 byte buf[] = new byte[1024];
>
> >                 System.out.println(tempDir.getAbsolutePath());
> >                 File temp = File.createTempFile("aaa", ".mp3", 
> > this.getCacheDir());
>
> >                 FileOutputStream out = new FileOutputStream(temp);
> >                 do {
> >                         int numread = is.read(buf);
> >                         if (numread <= 0)
> >                                 break;
> >                         out.write(buf, 0, numread);
> >                 } while (true);
> >                 out.flush();
> >                 out.close();
>
> >                 MediaPlayer mp = new MediaPlayer();
> >                 mp.setDataSource(temp.getAbsolutePath());
> >                 mp.prepare();
> >                 mp.start();
>
> >     I want to make some audio fragments to one audio file, and
> > MediaPlayer could not play with byte or stream, so I have to use
> > tempfile.
> >     upper code would: 11-05 05:47:37.512: WARN/System.err(3934):
> > java.io.IOException: Prepare failed.: status=0xFFFFFFFC.
> >     But, if I copy the temp file aaa.mp3 out by File Explore, and copy
> > it into cache directory, the aaa.mp3 could be played.
> >     The temp file created by app in linux is : -rw------- app_18
> > app_18  2868352 2008-11-05 03:54 aaa13710.mp3
> >     The file copyed into cache is : -rw-rw-rw- root     root
> > 2868352 2008-11-05 04:20 aaa13710.mp3
> >     The fiile copyed into sdcard is:----rw-rw- system   system
> > 2868352 2008-11-05 05:12 aaa13710.mp3
>
> >    so, I guess MediaPlayer play audio files with root account.
> > Although creating temp file into sdcard is one solution, but i don't
> > think it is a good method for slow efficiency. MediaPlay should be
> > able to play with stream or byte, and it is a strange thing that I
> > could create an audio file but play it.
> >     I saw other developers post this error, google wishes developer
> > create temp files into sdcard, in fact, creating temp file into sdcard
> > cann't solve anything.- 隐藏被引用文字 -
>
> - 显示引用的文字 -

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to