-
Notifications
You must be signed in to change notification settings - Fork 6k
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
ContentDataSource size determination issue #3426
Comments
I put some pending comments on the proposed fix. |
I played around with this a little by making a ContentProvider that returns a pipe. It looks like:
|
|
Are you certain |
I read it some where, can not find anymore, I think by "current" they mean size can be changed due to write operations. |
Ok, thanks. Can you provide some sample code showing how to create a |
Simple. I use ContentProvider urls to extract audio files from torrent/rar/zip archives for my torrent application. I patched it already. So, it returns AssetFileDescriptor.length, but if you drop such code it ExoPlayer fails again. In short 1) create pipe 2) create thread and start copying file to output steram. And second option, when you return file from file system (if content is torrent without archive): ParcelFileDescriptor[] ff = ParcelFileDescriptor.createPipe();
final ParcelFileDescriptor r = ff[0];
final ParcelFileDescriptor w = ff[1];
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
OutputStream os = new ParcelFileDescriptor.AutoCloseOutputStream(w);
try {
file.file.copy(os);
} catch (RuntimeException e) {
Log.d(TAG, "Error reading archive", e);
} finally {
try {
os.close();
} catch (IOException e) {
Log.d(TAG, "copy close error", e);
}
}
}
});
thread.start();
return r; EDIT: if available() returning the incorrect value then size() will be zero allways. |
Issue: #3426 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=174700804
We pushed a change that should fix this (see above). Please double check. Thanks! |
Issue: #3426 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=174700804
DefaultDataSource uses ContentDataSource to open urls. But ContentDataSource.open not following android documentations exactly and cause issues when opening url's in "r" mode only.
You can read ContentProvider.openFile documentation:
Since ContentDataSource uses "r" mode, ContentProvider may return Pipe instead of file and resulting bytes (total content length) will be miss detected:
Problem is, if ContentProvider retuns Pipe, ExoPlayer will stop playing audio after few seconds after fist seek action and close pipe before it fully readed. To fix this we may use open "rw" mode or wait until we reach EOF.
The text was updated successfully, but these errors were encountered: