VideoThumbnail:基于HarmonyOS的视频缩略图获取项目

用户可快速开发视频缩略图相关场景,如生成视频封面、辅助视频浏览分享。项目展示两种获取方法:通过getThumbnail()接口获取默认缩略图封面,通过AVImageGenerator类获取指定时间缩略图。

Branch1Tags0
FilesLast commitLast update
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago

Obtaining Video Thumbnails Using System Capabilities

Overview

This sample demonstrates two methods of obtaining video thumbnails: call getThumbnail() to obtain the default video thumbnail, or use the AVImageGenerator class to obtain the thumbnail of the video at the specified time. You can quickly develop the scenario where video thumbnails need to be obtained, for example, video browsing and sharing scenarios where users can quickly browse and select desired contents according to the video cover.

Preview

image

How to Use

  1. Touch the first button to start the gallery picker. After a video is selected, the application page displays the default video thumbnail.
  2. Touch the second button to start the gallery picker. After a video is selected, the application page displays the first frame of the video as the thumbnail. You can drag the progress bar below to select the thumbnail of the video at the specified time.

Project Directory

├──entry/src/main/ets
│  ├──common
│  │  └──utils 
│  │     ├──PhotoUtils.ets              // Image utility          
│  │     └──TimeUtils.ets               // Time utility 
│  ├──entryability
│  │  └──EntryAbility.ets               // Entry ability 
│  ├──entrybackupability
│  │  └──EntryBackupAbility.ets        
│  ├──model
│  │  └──VideoSizeData.ets              // Video data
│  └──pages                  
│     └──Index.ets                      // Home page
└──entry/src/main/resource              // Static resources of the application

Permissions

  • N/A

Constraints

  1. The sample is only supported on Huawei phones with standard systems.
  2. The HarmonyOS version must be HarmonyOS 5.0.5 Release or later.
  3. The DevEco Studio version must be DevEco Studio 5.0.5 Release or later.
  4. The HarmonyOS SDK version must be HarmonyOS 5.0.5 Release SDK or later.

Introduction

用户可快速开发视频缩略图相关场景,如生成视频封面、辅助视频浏览分享。项目展示两种获取方法:通过getThumbnail()接口获取默认缩略图封面,通过AVImageGenerator类获取指定时间缩略图。

Customize your domain