如何将视频缩略图发送到在线服务器 [英] How to send video thumbnail to online server

查看:35
本文介绍了如何将视频缩略图发送到在线服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在开发 android 中的视频应用程序,我想生成视频缩略图并将其发送到服务器或简单如何获取视频缩略图并存储在服务器中,以便在我检索视频时也可以将视频缩略图发送到在回收视图中使用谢谢

Hi am working on a video app in android i want to generate video thumbnail and send to the server or simple how can i get video thumbnail and store in server so that when i retrieve the video i can also get the video thumbnail to use in a recycle view thanks

Bitmap thumb = ThumbnailUtils.createVideoThumbnail(filePath,
                MediaStore.Images.Thumbnails.MINI_KIND);
        BitmapDrawable bitmapDrawable = new BitmapDrawable(thumb);
        vidPreview.setBackgroundDrawable(bitmapDrawable); 

推荐答案

我假设您也将视频发送到服务器?如果是这样,那么最好在服务器上生成缩略图,因为您通常在那里拥有更多的处理能力,而不必担心消耗电池.它还使您不必将生成的缩略图发送到服务器.

I assume you are sending the video to the server also? If so then it may be better to generate the thumbnail on the server as you usually have more processing power there and less worry about consuming battery. It also saves you having to send the generated thumbnail to the server.

如果您确实想在 Android 设备上创建缩略图,那么以下代码将起作用(在此块之前,应用程序已使用加载器模式加载了媒体商店中的所有视频,并且可以通过下面的光标"变量访问它们) - 查看getThumbnail"方法调用:

If you do want to create the thumbnail on the Android device then the following code will work (before this chunk the app has loaded all the videos in Media Store using the loader pattern and they are accessible via the 'cursor' variable below) - see the 'getThumbnail' method call:

while (videoCursor.moveToNext()) {
            //Create the Thumbnail for this video
            Log.d("ItemListFragment", "onLoadFinished: Creating Thumbnail");
            String videoTitle = videoCursor.getString(titleColumn_index);
            String videoPath = videoCursor.getString(pathColumn_index);
            long videoID = videoCursor.getLong(idColumn_index);
            Bitmap thisVideoThumbnail = MediaStore.Video.Thumbnails.getThumbnail(this.getActivity().getContentResolver(), videoID, MediaStore.Images.Thumbnails.MINI_KIND, null);
            if (thisVideoThumbnail == null) {
                Log.d("VideoContent refresh ","VideoThumbnail is null!!!");
            }
            VideoItem newVideoItem = new VideoItem(videoID, videoTitle, videoPath, thisVideoThumbnail);
            //Add the new video item to the list
            videosArray.addItem(newVideoItem);
        }

这篇关于如何将视频缩略图发送到在线服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆