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

add mp4movie custom resolution support #30

Merged
merged 4 commits into from
Feb 10, 2025
Merged

Conversation

ck2739046
Copy link
Contributor

@ck2739046 ck2739046 commented Feb 9, 2025

前两天修的封面比例问题,也可以适用于mp4movie比例
这样就能正常播放非16:9的mp4文件了,不知道有没有人会用到这个需求...

Summary by Sourcery

添加对 mp4 电影自定义分辨率的支持。更新配置描述以反映新功能。

新功能:

  • 支持 mp4 电影的自定义分辨率,允许播放非 16:9 宽高比的视频。

测试:

  • 更新测试以覆盖新的分辨率功能。
Original summary in English

Summary by Sourcery

Add support for custom resolutions for mp4 movies. Update the configuration descriptions to reflect the new functionality.

New Features:

  • Support custom resolutions for mp4 movies, allowing playback of non-16:9 aspect ratio videos.

Tests:

  • Update tests to cover the new resolution functionality.

Copy link

sourcery-ai bot commented Feb 9, 2025

审阅者指南 by Sourcery

这个拉取请求通过为 mp4 电影添加自定义分辨率支持来增强 MovieLoader。更改包括更新配置优先级,引入异步回调以根据视频的长宽比调整视频尺寸,并修改检索电影尺寸的方式。

MovieLoader 中异步视频分辨率调整的序列图

sequenceDiagram
    participant VP as VideoPlayer
    participant ML as MovieLoader
    VP->>ML: Trigger prepareCompleted(source)
    activate ML
    ML->>ML: Retrieve width & height from VideoPlayer
    ML->>ML: Calculate new bgaSize based on:
    ML->>ML: if (height > width) then [1080, 1080 * width/height]
    ML->>ML: else [1080 * height/width, 1080]
    ML-->>VP: bgaSize updated
    deactivate ML
Loading

带有自定义分辨率支持的 MovieLoader 更新类图

classDiagram
    class MovieLoader {
        -bool loadSourceMovie
        -bool loadMp4Movie = false
        -string movieAssetsDir = "LocalAssets"
        -bool jacketAsMovie
        -uint[] bgaSize = [0, 0]
        -Dictionary~string, string~ optionFileMap
        +LoadLocalBgaAwake(____movieMaskObj: GameObject, ___monitorIndex: int)
        +GetMovieHeightPostfix(ref __result: uint)
        +GetMovieWidthPostfix(ref __result: uint)
    }

    %% Note: LoadLocalBgaAwake now attaches an asynchronous callback to VideoPlayer.prepareCompleted
    note for MovieLoader "处理 mp4 电影的自定义分辨率调整"
Loading

文件级更改

更改 详情 文件
更新加载电影的配置条目和默认设置
  • 重新表述配置描述以澄清优先级:游戏源 PV > 本地 mp4 PV > 封面
  • 将加载 mp4 电影的默认值更改为 false
  • 将 jacketAsMovie 配置条目重新定位到 MP4 配置之后
AquaMai.Mods/GameSystem/Assets/MovieLoader.cs
为 mp4 电影引入自定义分辨率逻辑
  • 删除旧的 isLoadingJacket 标志,并用新的 bgaSize 数组存储宽度和高度
  • 在 VideoPlayer 的 prepareCompleted 事件上添加异步回调以检索视频的宽度和高度
  • 计算适当的缩放以将视频放入 (1080, 1080) 帧中,同时保持长宽比
AquaMai.Mods/GameSystem/Assets/MovieLoader.cs
修改电影背景的尺寸检索逻辑
  • 更新 GetMovieHeightPostfix 以使用新的 bgaSize 数组,使用后重置存储的高度
  • 更新 GetMovieWidthPostfix 以使用新的 bgaSize 数组,使用后重置存储的宽度
  • 增强日志记录以在没有封面或背景动画时提供更多上下文
AquaMai.Mods/GameSystem/Assets/MovieLoader.cs

提示和命令

与 Sourcery 交互

  • 触发新的审阅: 在拉取请求上评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的审阅评论。
  • 从审阅评论生成 GitHub 问题: 通过回复审阅评论,要求 Sourcery 创建一个问题。您也可以用 @sourcery-ai issue 回复审阅评论以创建问题。
  • 生成拉取请求标题: 在拉取请求标题的任何位置写 @sourcery-ai 以随时生成标题。您也可以在拉取请求上评论 @sourcery-ai title 以随时(重新)生成标题。
  • 生成拉取请求摘要: 在拉取请求正文的任何位置写 @sourcery-ai summary 以随时生成 PR 摘要。您也可以在拉取请求上评论 @sourcery-ai summary 以随时(重新)生成摘要。
  • 生成审阅者指南: 在拉取请求上评论 @sourcery-ai guide 以随时(重新)生成审阅者指南。
  • 解决所有 Sourcery 评论: 在拉取请求上评论 @sourcery-ai resolve 以解决所有 Sourcery 评论。如果您已经处理了所有评论,不想再看到它们,这很有用。
  • 取消所有 Sourcery 审阅: 在拉取请求上评论 @sourcery-ai dismiss 以取消所有现有的 Sourcery 审阅。特别是在您想重新开始审阅时很有用 - 别忘了评论 @sourcery-ai review 以触发新的审阅!
  • 为问题生成行动计划: 在问题上评论 @sourcery-ai plan 以生成问题的行动计划。

自定义您的体验

访问您的仪表板以:

  • 启用或禁用审阅功能,如 Sourcery 生成的拉取请求摘要、审阅者指南等。
  • 更改审阅语言。
  • 添加、删除或编辑自定义审阅说明。
  • 调整其他审阅设置。

获取帮助

Original review guide in English

Reviewer's Guide by Sourcery

This pull request enhances the MovieLoader by adding custom resolution support for mp4 movies. The changes include updating configuration priorities, introducing an asynchronous callback to adjust the video dimensions based on the video's aspect ratio, and modifying how the movie dimensions are retrieved.

Sequence diagram for asynchronous video resolution adjustment in MovieLoader

sequenceDiagram
    participant VP as VideoPlayer
    participant ML as MovieLoader
    VP->>ML: Trigger prepareCompleted(source)
    activate ML
    ML->>ML: Retrieve width & height from VideoPlayer
    ML->>ML: Calculate new bgaSize based on:
    ML->>ML: if (height > width) then [1080, 1080 * width/height]
    ML->>ML: else [1080 * height/width, 1080]
    ML-->>VP: bgaSize updated
    deactivate ML
Loading

Updated class diagram for MovieLoader with custom resolution support

classDiagram
    class MovieLoader {
        -bool loadSourceMovie
        -bool loadMp4Movie = false
        -string movieAssetsDir = "LocalAssets"
        -bool jacketAsMovie
        -uint[] bgaSize = [0, 0]
        -Dictionary~string, string~ optionFileMap
        +LoadLocalBgaAwake(____movieMaskObj: GameObject, ___monitorIndex: int)
        +GetMovieHeightPostfix(ref __result: uint)
        +GetMovieWidthPostfix(ref __result: uint)
    }

    %% Note: LoadLocalBgaAwake now attaches an asynchronous callback to VideoPlayer.prepareCompleted
    note for MovieLoader "Handles custom resolution adjustment for mp4 movies via bgaSize"
Loading

File-Level Changes

Change Details Files
Updated configuration entries and default settings for loading movies
  • Reworded configuration descriptions to clarify the priority: game source PV > local mp4 PV > jacket
  • Changed the default value for loading mp4 movies to false
  • Repositioned the jacketAsMovie configuration entry to appear after the MP4 configuration
AquaMai.Mods/GameSystem/Assets/MovieLoader.cs
Introduced custom resolution logic for mp4 movies
  • Removed the old isLoadingJacket flag and replaced it with a new bgaSize array to store width and height
  • Added an asynchronous callback on the VideoPlayer’s prepareCompleted event to retrieve the video's width and height
  • Calculated proper scaling to fit the video into a (1080, 1080) frame while preserving the aspect ratio
AquaMai.Mods/GameSystem/Assets/MovieLoader.cs
Modified dimension retrieval logic for movie backgrounds
  • Updated the GetMovieHeightPostfix to use the new bgaSize array, resetting the stored height after use
  • Updated the GetMovieWidthPostfix to use the new bgaSize array, resetting the stored width after use
  • Enhanced logging to provide more context when neither a jacket nor a bga is available
AquaMai.Mods/GameSystem/Assets/MovieLoader.cs

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

@ck2739046 - 我已经审查了你的更改 - 以下是一些反馈:

整体评论

  • 考虑将 bgaSize 数组重命名并重构为专门的结构,以更清晰地表示宽度和高度。
  • 仔细检查将 loadMp4Movie 的默认值从 true 更改为 false 是否符合预期行为。
以下是我在审查期间查看的内容
  • 🟢 一般问题:一切看起来都很好
  • 🟢 安全性:一切看起来都很好
  • 🟢 测试:一切看起来都很好
  • 🟢 复杂性:一切看起来都很好
  • 🟢 文档:一切看起来都很好

Sourcery 对开源项目是免费的 - 如果你喜欢我们的评论,请考虑分享它们 ✨
帮助我变得更有用!请在每条评论上点击 👍 或 👎,我将使用这些反馈来改进你的评论。
Original comment in English

Hey @ck2739046 - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider renaming and refactoring the bgaSize array into a dedicated structure to more clearly represent width and height.
  • Double-check that changing the default of loadMp4Movie from true to false aligns with the intended behavior.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@clansty
Copy link
Contributor

clansty commented Feb 10, 2025

我就说为什么我视频放进去会变成方的

@clansty clansty merged commit 4837c2f into MewoLab:main Feb 10, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants