Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: add ShortVideo message support #2739

Merged
merged 44 commits into from
Aug 20, 2023
Merged

feature: add ShortVideo message support #2739

merged 44 commits into from
Aug 20, 2023

Conversation

StageGuard
Copy link
Member

@StageGuard StageGuard commented Jul 17, 2023

close #867, #1664, #2011, partially #2621


短视频消息 ShortVideo

短视频消息,指的是可在聊天界面在线播放的视频消息,而非在群文件上传的视频文件.

短视频消息分为 OnlineShortVideoOfflineShortVideo. 在本地上传的短视频为 OfflineShortVideo. 从服务器接收的短视频为 OnlineShortVideo.

最推荐存储的方式是下载视频文件,每次都通过上传该文件获取视频消息.
在上传视频时服务器会根据缓存情况选择回复已有视频 ID 或要求客户端上传.

获取短视频消息示例

上传短视频

使用 Contact.uploadShortVideo,将视频缩略图和视频资源``ExternalResource 上传以得到 OfflineShortVideo.

使用 Builder 构建短视频

ShortVideo 提供 Builder 构建方式,必须指定 videoId, fileName, fileMd5, fileSizefileFormat 参数.
可选指定 Builder.thumbnailMd5Builder.thumbnailSize. 若不提供,可能会影响服务器判断缓存.

从服务器接收

通过监听消息接收的短视频消息可直接转换为 OnlineShortVideo.

下载视频

通过 OnlineShortVideo.urlForDownload 获取下载链接.
该下载链接不包含短视频的文件信息,可以使用 videoIdfileName 作为文件名,fileFormat 作为文件拓展名.

其他信息

mirai 码支持

ShortVideo 不支持 mirai 码,意味着如果通过 mirai 码持久化消息,短视频消息将不会被存储.

@StageGuard StageGuard linked an issue Jul 24, 2023 that may be closed by this pull request
@StageGuard StageGuard added t:feature 类型: 新特性 x:protocol 属性: 协议相关 N 优先级: 一般 s:core 子系统: mirai-core labels Jul 24, 2023
@Him188
Copy link
Member

Him188 commented Jul 29, 2023

好了叫我 review 一下

@StageGuard StageGuard marked this pull request as ready for review August 2, 2023 09:45
@StageGuard StageGuard requested a review from Him188 August 2, 2023 09:45
@Him188 Him188 self-requested a review August 15, 2023 12:35
StageGuard added 2 commits August 16, 2023 22:41
# Conflicts:
#	mirai-core-api/src/commonMain/kotlin/contact/Contact.kt
#	mirai-core-api/src/jvmBaseMain/kotlin/contact/Contact.kt
#	mirai-core-api/src/jvmBaseMain/kotlin/utils/ExternalResource.kt
@StageGuard StageGuard requested a review from Him188 August 16, 2023 15:19
@Lawaxi
Copy link

Lawaxi commented Aug 17, 2023

无比期待

@Lawaxi
Copy link

Lawaxi commented Aug 17, 2023

Contact.uploadShortVideo必须要有缩略图吗

@StageGuard
Copy link
Member Author

Contact.uploadShortVideo必须要有缩略图吗

协议上是需要。在 QQ 客户端中通常是自动截取视频文件中间的某一帧作为缩略图。但是 mirai 没有解码视频的能力,所以需要用户自行处理。

@Him188 Him188 added this to the 2.16.0-RC milestone Aug 20, 2023
Copy link
Member

@Karlatemp Karlatemp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No other issue

@StageGuard StageGuard merged commit 5b3e508 into dev Aug 20, 2023
2 checks passed
@StageGuard StageGuard deleted the short-video-message branch August 20, 2023 10:41
@landall
Copy link

landall commented Aug 20, 2023

牛逼!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
N 优先级: 一般 s:core 子系统: mirai-core t:feature 类型: 新特性 x:protocol 属性: 协议相关
Projects
None yet
Development

Successfully merging this pull request may close these issues.

支持视频短片类型 支持发送视频
5 participants