【问题标题】:How to send video thumbnail to online server如何将视频缩略图发送到在线服务器
【发布时间】:2016-05-17 01:50:01
【问题描述】:

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

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

【问题讨论】:

标签: android video


【解决方案1】:

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

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

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);
        }

【讨论】:

    猜你喜欢
    • 2015-06-14
    • 1970-01-01
    • 2016-06-20
    • 2018-04-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-27
    相关资源
    最近更新 更多