Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4362: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4364: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4365: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4366: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
anddev.org • View topic - Media Player setDataSource with FileDescriptor

Media Player setDataSource with FileDescriptor

All your problems with Audio, Video and Images.

Media Player setDataSource with FileDescriptor

Postby wpaccount » Wed Nov 25, 2009 6:25 am

I have problem with setDataSource(FileDescriptor) or setDataSource(FileDescriptor, offset, length).

The following works:
...
case LOCAL_AUDIO:
path = "/sdcard/sample.wav";
mMediaPlayer = new MediaPlayer();
mMediaPlayer.setDataSource(path); // this works
mMediaPlayer.prepare();
mMediaPlayer.start();
...

If I use the following, a prepare() error and setDatasource() error throwed as IOException both on emulator 1.6 and 2.0:
....
// sample.wav has size about 400,000 bytes
File f = new File(android.os.Environment.getExternalStorageDirectory()+"/sample.wav");
FileInputStream fileIS = null;
FileDescriptor fd = null;
fileIS = new FileInputStream(f);
fd = fileIS.getFD(); // seems work as no "Filenotfound" exception throwed
mMediaPlayer = new MediaPlayer();
mMediaPlayer.setDataSource(fd, 1, 200000); // error
mMediaPlayer.prepare(); // error , prepareAsync() also doesn't work
mMediaPlayer.start();
....

I am new to android and is it wrong with the filestream / filedescriptor?

Thanks in advance for any help!
wpaccount
Once Poster
Once Poster
 
Posts: 1
Joined: Wed Nov 25, 2009 6:06 am

Top

Postby nithin.warier » Fri Nov 27, 2009 9:06 am

Hi wpaccount,

Put your media file in raw folder and use AssetFileDescriptor.
Then From AssetFileDescriptor, use the function getFileDescriptor() to get fileDescriptor.

AssetFileDescriptor afd = context.getResources().openRawResourceFd(
R.raw.filename);


Thanks
smartandroidians.blogspot.com
nithin.warier
Experienced Developer
Experienced Developer
 
Posts: 87
Joined: Thu Feb 28, 2008 12:05 pm
Location: Malappuram Kerala India

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 7 guests