Open mafshin opened 10 years ago
metaData.getFrameAtTime(position)
Vitamio demo have sample.
The undocumented fix was this just after getFrameAt
metaData.release();
Finally, using metaData.release();
I got it working, but yet there's another problem and it's the Parallel Execution. The Android SDK MetaDataRetriever
works very well when called in a parallel AsyncTask
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
frameGeneratorAsyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, args);
else
frameGeneratorAsyncTask.execute(args);
but, the Vitamio MetaDataRetriever
only works in sequential mode.
FrameGeneratorAsyncTask:
protected Bitmap doInBackground(Object... objects) {
Context context = (Context) objects[0];
String path = objects[1].toString();
long position = (Long) objects[2];
Bitmap frame = null;
MediaMetadataRetriever metaData = null;
try {
metaData = new MediaMetadataRetriever(context);
metaData.setDataSource(path);
frame = metaData.getFrameAtTime(position);
} catch (Exception e) {
Log.e(TAG, "FrameGeneratorAsyncTask Error");
}finally {
if(metaData != null)
metaData.release();
}
return frame;
}
In my case, I had to wait till all previous frames (for previous items) get generated (sequential) while using Android SDK MetaDataRetriever
, the frames are generated in parallel. In other words, the app can't benefit from modern smartphones multi-core power.
I need this too, is useful to generate thumbnail with multithread
The MediaMetaDataRetriever class doesn't work as expected. It stuck on setDataSource and never returns the frame (Its in an AsyncTask so it does not block)
MediaMetadataRetriever metaData = new MediaMetadataRetriever(); metaData.setDataSource(path); Bitmap frame = metaData.getFrameAtTime(position * 1000);
Tested on GS4.
[See my last post]