Skip to content

Conversation

@naylinndev
Copy link

Fixed audio track and subtitle track issues in Android after updated Android VLC player V4.0.0

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @naylinndev, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses compatibility issues and introduces enhancements by upgrading the underlying VLC player library on Android to version 4.0.0. It involves a comprehensive update of the platform-specific code, particularly for Android and iOS, to integrate with the new VLC APIs and align with the latest Pigeon messaging conventions. The changes aim to resolve existing track-related problems and ensure the player's functionality remains robust with modern dependencies.

Highlights

  • Android VLC Player Update: The Android VLC player dependency has been updated to version 4.0.0-eap21, requiring significant adaptations to the API usage for track management (audio, video, subtitles) and other player functionalities.
  • Pigeon Messaging System Refactor: The Pigeon messaging system has been updated, leading to changes in message structures and the regeneration of platform interface files for both Android and iOS. This includes new message classes and updated method signatures.
  • Kotlin and iOS Deployment Target Updates: The Kotlin version for Android has been upgraded to 2.1.0, and the minimum iOS deployment target has been raised to 13.0, ensuring compatibility with newer development environments and features.
  • Track Management API Changes: The methods for retrieving and setting audio, video, and subtitle tracks have been refactored to align with the new VLC 4.0.0 API, utilizing IMedia.Track for more robust track handling.
  • Code Cleanup and Modernization: Various parts of the codebase have been cleaned up, including the removal of commented-out code, unnecessary comments, and adjustments to enum definitions for better type safety and consistency.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the Android VLC player dependency to version 4.0.0 and adapts the codebase to the new API, fixing audio and subtitle track issues. The changes are extensive, especially in the native Android and iOS code, to align with the updated Pigeon-generated interfaces. While the effort to adapt to the new API is commendable, I've identified several critical issues related to null safety and potential crashes in both the Android (Java) and iOS (Swift) implementations. These issues stem from missing null checks that were present in the previous version, and force unwrapping of optional values. I've also found some minor issues like copy-paste errors in log messages and code formatting inconsistencies. Addressing the critical issues is essential to ensure the stability of the plugin.

Comment on lines +442 to +453
try {

if ( index >= 0) {
// Select the track by its ID
mediaPlayer.selectTrack("audio/"+index);
} else if (index == -1) {
// Unselect all audio tracks
mediaPlayer.unselectTrackType(IMedia.Track.Type.Audio);
}
} catch (Exception e) {
Log.e(TAG, "setAudioTrack failed: " + e.getMessage());
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The code formatting in this method is inconsistent with standard Java conventions, which affects readability. The empty line and indentation should be fixed.

        try {
            if (index >= 0) {
                // Select the track by its ID
                mediaPlayer.selectTrack("audio/" + index);
            } else if (index == -1) {
                // Unselect all audio tracks
                mediaPlayer.unselectTrackType(IMedia.Track.Type.Audio);
            }
        } catch (Exception e) {
            Log.e(TAG, "setAudioTrack failed: " + e.getMessage());
        }

Comment on lines 11 to 14
DataSourceType (int type)
{
this.mType = type;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The constructor formatting is unconventional for Java. It's better to follow standard Java conventions for consistency and readability. Specifically, the space before the parameter list and the placement of curly braces can be improved.

    DataSourceType(int type) {
        this.mType = type;
    }

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it's a reasonable comment - can we fix it?

Comment on lines 12 to 15
HwAcc (int type)
{
this.mType = type;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The constructor formatting is unconventional for Java. It's better to follow standard Java conventions for consistency and readability. Specifically, the space before the parameter list and the placement of curly braces can be improved.

    HwAcc(int type) {
        this.mType = type;
    }

Comment on lines +612 to +613
enum HWAccellerationType: Int
{
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we rool-back those formatting changes to avoid tracking it in the diff? Any reason we want to re-format?

Copy link
Author

Choose a reason for hiding this comment

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

When I tried using the master branch, I couldn’t run it on iOS.
Then I pulled the code directly from tag 7.4.4, which contains the HWAccellerationType code.
I mean there were no changes for iOS—I just pulled the code from tag 7.4.4 to make the example app run.

Copy link
Collaborator

@illia-romanenko illia-romanenko left a comment

Choose a reason for hiding this comment

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

Thanks for your PR! Please review comments by Gemini in formatting other cases and resolve them as I think the package in general will benefit from it. Looking forward to merge it.

@Chau14022000
Copy link

@naylinndev
Have you tried testing with this example:
Play the video → pause for 5 seconds → seek to 15s → then play again?
When I tested it, the playback position after resuming didn’t seem correct.

By the way, may I ask why we needed to change the minimum SDK version?

Thank you! 🙏

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.

3 participants