Skip to content

Commit

Permalink
Display the gif of the comments (only the first frame is displayed)
Browse files Browse the repository at this point in the history
  • Loading branch information
xfangfang committed Nov 11, 2023
1 parent 5a5fe86 commit f43a295
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
13 changes: 12 additions & 1 deletion wiliwili/source/fragment/player_single_comment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,8 +447,19 @@ PlayerCommentAction::PlayerCommentAction() {
});
this->svgGallery->registerClickAction([this](...) {
std::vector<std::string> data;
#ifdef __PSV__
const std::string note_raw_ext = "@300h.jpg";
#else
const std::string note_raw_ext = "@!web-comment-note.jpg";
#endif
for (auto& i : this->comment->getData().content.pictures) {
data.emplace_back(i.img_src + ImageHelper::note_raw_ext);
std::string raw_ext = ImageHelper::note_raw_ext;
if (i.img_src.size() > 4 &&
i.img_src.substr(i.img_src.size() - 4, 4) == ".gif") {
// gif 图片暂时按照 jpg 来解析
raw_ext = note_raw_ext;
}
data.emplace_back(i.img_src + raw_ext);
}
Intent::openGallery(data);
return true;
Expand Down
10 changes: 9 additions & 1 deletion wiliwili/source/view/video_comment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,16 @@ void VideoComment::setData(bilibili::VideoCommentResult data) {
w = picture.img_width / picture.img_height * h;
if (w > maxSize) w = maxSize;
}

const std::string custom_ext_jpg = "@{}w_{}h_85q_!note-comment-multiple.jpg";
std::string custom_ext = ImageHelper::note_custom_ext;
if (picture.img_src.size() > 4 &&
picture.img_src.substr(picture.img_src.size() - 4, 4) == ".gif") {
// gif 图片暂时按照 jpg 来解析
custom_ext = custom_ext_jpg;
}
auto item = std::make_shared<RichTextImage>(
picture.img_src + wiliwili::format(ImageHelper::note_custom_ext,
picture.img_src + wiliwili::format(custom_ext,
#ifdef __PSV__
(int)(w * 0.5), (int)(h * 0.5)),
#else
Expand Down

0 comments on commit f43a295

Please sign in to comment.