4

in my android TV application, at start i want to show a frame of my each stream links. my current solution is using LoaderManager and the problem of this technique is to it's too slow(application crashed).

FFmpegMediaMetadataRetriever to load and set video stream link.
this.retriever = new FFmpegMediaMetadataRetriever();
Bitmap bitmap = null;
retriever.setDataSource(this.mSelectedStream.getStreamUrl());
bitmap = retriever.getFrameAtTime();
drawable = new BitmapDrawable(bitmap);
retriever.release();

i found this thread that explain that glide can used to load image from video links.

BitmapPool bitmapPool = Glide.get(getApplicationContext()).getBitmapPool();
                int microSecond = 6000000;// 6th second as an example
                VideoBitmapDecoder videoBitmapDecoder = new VideoBitmapDecoder(microSecond);
                FileDescriptorBitmapDecoder fileDescriptorBitmapDecoder = new FileDescriptorBitmapDecoder(videoBitmapDecoder, bitmapPool, DecodeFormat.PREFER_ARGB_8888);
                Glide.with(getApplicationContext())
                        .load(yourUri)
                        .asBitmap()
                        .override(50,50)// Example
                        .videoDecoder(fileDescriptorBitmapDecoder)
                        .into(yourImageView);

but when i used above code i get "cannot access from outside of package" error for VideoBitmapDecoder.

exmaple link = "http://devimages.apple.com/iphone/samples/bipbop/gear1/prog_index.m3u8"

any idea? thanks

destrat18
  • 197
  • 2
  • 14

1 Answers1

0

I've used this snippet to get thumb nail out of video frames. Try it

 Bitmap thumbnail = ThumbnailUtils.createVideoThumbnail(media_url,
                MediaStore.Images.Thumbnails.MINI_KIND);
        BitmapDrawable BD = new BitmapDrawable(thumbnail);
        videoView.setBackgroundDrawable(BD);
Ashutosh Sagar
  • 981
  • 8
  • 20