-
Notifications
You must be signed in to change notification settings - Fork 8.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can the IjkMediaPlayer play the Android raw resource files? #1013
Comments
No. |
how to modify the dir let ijkplayer play? |
Implement IMediaDataSource |
I called the setDataSource by: if(mUri.getScheme().equals(ContentResolver.SCHEME_ANDROID_RESOURCE)) {
AssetFileDescriptor fileDescriptor = getContext().getContentResolver().openAssetFileDescriptor(mUri, "r");
IMediaDataSource dataSource = new RawDataSourceProvider(fileDescriptor);
if(fileDescriptor != null)
mMediaPlayer.setDataSource(dataSource);
else{
release(false);
return ;
}
} I implement IMediaDataSource by myself but ijkplayer does't working.Are there any problems? class RawDataSourceProvider implements IMediaDataSource{
AssetFileDescriptor mDescriptor;
public RawDataSourceProvider(AssetFileDescriptor descriptor) {
this.mDescriptor = descriptor;
}
@Override
public int readAt(long position, byte[] buffer, int offset, int size) throws IOException {
InputStream is = mDescriptor.createInputStream();
if(is != null) {
return is.read(buffer, offset, size);
}
return -1;
}
@Override
public long getSize() throws IOException {
return mDescriptor.getLength();
}
@Override
public void close() throws IOException {
mDescriptor.close();
}
} |
change |
@linwea Does it normally work for you ? |
@yjwfn yes |
播放本地资源要怎么填URI,找不到啊,不科学 |
I use this: (on kotlin)
|
mark |
I have a video in Android raw directory.
Like this:
android.resource://com.lianlian.fitness/raw/2131165184
Can The IjkMediaPlayer play the Uri?
The text was updated successfully, but these errors were encountered: