Add linkPreviewTypeEmbeddedAudioPlayer/linkPreviewTypeEmbeddedVideoPlayer.

This commit is contained in:
levlam 2024-07-04 13:28:35 +03:00
parent f1a08b3559
commit baec4850ae
2 changed files with 30 additions and 0 deletions

View File

@ -2565,6 +2565,20 @@ linkPreviewTypeChannelBoost photo:chatPhoto = LinkPreviewType;
//@creates_join_request True, if the link only creates join request
linkPreviewTypeChat type:InviteLinkChatType photo:chatPhoto creates_join_request:Bool = LinkPreviewType;
//@description The link is a link to an audio player
//@url URL of the external audio player
//@duration Duration of the audio, in seconds
//@author Author of the audio
linkPreviewTypeEmbeddedAudioPlayer url:string duration:int32 author:string = LinkPreviewType;
//@description The link is a link to a video player
//@url URL of the external video player
//@duration Duration of the video, in seconds
//@author Author of the video
//@width Expected width of the preview
//@height Expected height of the preview
linkPreviewTypeEmbeddedVideoPlayer url:string duration:int32 author:string width:int32 height:int32 = LinkPreviewType;
//@description The link is a link to an invoice
linkPreviewTypeInvoice = LinkPreviewType;

View File

@ -1425,6 +1425,22 @@ td_api::object_ptr<td_api::LinkPreviewType> WebPagesManager::get_link_preview_ty
get_chat_photo_object(td_->file_manager_.get(), web_page->photo_), false);
}
}
if (!web_page->embed_type_.empty() || !web_page->embed_url_.empty()) {
if (web_page->embed_type_ == "iframe") {
if (web_page->type_ == "audio") {
return td_api::make_object<td_api::linkPreviewTypeEmbeddedAudioPlayer>(web_page->embed_url_,
web_page->duration_, web_page->author_);
}
if (web_page->type_ == "video") {
return td_api::make_object<td_api::linkPreviewTypeEmbeddedVideoPlayer>(
web_page->embed_url_, web_page->duration_, web_page->author_, web_page->embed_dimensions_.width,
web_page->embed_dimensions_.height);
}
LOG(ERROR) << "Have type = " << web_page->type_ << " for embedded " << web_page->url_;
return td_api::make_object<td_api::linkPreviewTypeOther>(web_page->type_);
}
// ordinary audio/video
}
// TODO LOG(ERROR) << "Receive link preview of unsupported type " << web_page->type_;
return td_api::make_object<td_api::linkPreviewTypeOther>(web_page->type_);
}