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

Cross-platform media controller for video playback #1845

Merged
merged 25 commits into from
Apr 24, 2024

Conversation

rh101
Copy link
Contributor

@rh101 rh101 commented Apr 23, 2024

Describe your changes

This PR is to add a media controller to video playback, which works across all supported platforms and media engine backends.

  • AndroidMediaEngine
  • AvfMediaEngine
  • MfMediaEngine
  • VlcMediaEngine
  • WmfMediaEngine

@halx99 Is the VLC engine only for Linux? Attempting to compile it on Windows ended up with this error:
3>Error copying directory from "G:/game_engines/axmol/3rdparty/vlc/win/lib/vlc/plugins" to "G:/dev/public/tests/videotest/build_x64/bin/videotest/Debug/plugins".

I don't see the vlc folder in the axmol/3rdparty either, and I'm not sure what else I need to do besides enable it via set(AX_ENABLE_VLC_MEDIA ON CACHE BOOL "" FORCE).

By default the player controls are off. Would it be preferrable to have them disabled by default?

At the moment, to enable or disable them, just use VideoPlayer::setUserInputEnabled(). For example:

auto* videoPlayer = ui::VideoPlayer::create();
videoPlayer->play();
videoPlayer->setUserInputEnabled(true);

The default media controller can also be overriden with a custom version, and applied to the video player via MediaPlayer::setMediaController(MediaController* controller).

The Android implementation required a work-around, since there was no way to retrieve the content duration and current time directly. It has to happen in callbacks, but I'm not sure if the solution implemented in this PR is the most appropriate, so please review that, specifically the code in AxmolMediaEngine.java, method processVideoFrame, where it calls back with the current video playback time.

Issue ticket number and link

#1811

Checklist before requesting a review

For each PR

  • Add Copyright if it missed:
    - "Copyright (c) 2019-present Axmol Engine contributors (see AUTHORS.md)."

  • I have performed a self-review of my code.

    Optional:

    • I have checked readme and add important infos to this PR.
    • I have added/adapted some tests too.

For core/new feature PR

  • I have checked readme and add important infos to this PR.
  • I have added thorough tests.

@halx99 halx99 added the media label Apr 23, 2024
@halx99 halx99 added this to the 2.1.3 milestone Apr 23, 2024
@halx99 halx99 linked an issue Apr 23, 2024 that may be closed by this pull request
@aismann
Copy link
Contributor

aismann commented Apr 23, 2024

@rh101
Please add a copyright header/comment on each file too

@halx99
Copy link
Collaborator

halx99 commented Apr 23, 2024

@halx99 Is the VLC engine only for Linux? Attempting to compile it on Windows ended up with this error:
3>Error copying directory from "G:/game_engines/axmol/3rdparty/vlc/win/lib/vlc/plugins" to "G:/dev/public/tests/videotest/build_x64/bin/videotest/Debug/plugin

Yes, it's only for linux, and axmol prebuilt libvlc not work for current axmol version

@rh101 rh101 marked this pull request as draft April 23, 2024 08:18
@rh101
Copy link
Contributor Author

rh101 commented Apr 23, 2024

Currently in the process of testing the Linux version, and fixing a few issues related to content scaling. I'm trying to convert this PR to a draft with the button on github, but it's not letting me, so for the time being, please don't merge anything in.

@rh101
Copy link
Contributor Author

rh101 commented Apr 23, 2024

Linux version runs, but I'm having issues with missing media player control font characters. The Android version is also missing the play button font character, yet all the other buttons appear correctly, so another issue with the fonts on that system.

I'm not sure how to resolve this without using image files, but with image files, to not look pixelated, they end up as 3-4K file each, so the resulting base64 encoded PNGs are pretty large.

Any suggestions?

@halx99
Copy link
Collaborator

halx99 commented Apr 23, 2024

Linux version runs, but I'm having issues with missing media player control font characters. The Android version is also missing the play button font character, yet all the other buttons appear correctly, so another issue with the fonts on that system.

I'm not sure how to resolve this without using image files, but with image files, to not look pixelated, they end up as 3-4K file each, so the resulting base64 encoded PNGs are pretty large.

Any suggestions?

Use drawNode to draw control buttons shape?

@halx99
Copy link
Collaborator

halx99 commented Apr 23, 2024

By default the player controls are on. Would it be preferrable to have them disabled by default?

disable by default maybe better

@halx99
Copy link
Collaborator

halx99 commented Apr 23, 2024

Linux version runs, but I'm having issues with missing media player control font characters. The Android version is also missing the play button font character, yet all the other buttons appear correctly, so another issue with the fonts on that system.
I'm not sure how to resolve this without using image files, but with image files, to not look pixelated, they end up as 3-4K file each, so the resulting base64 encoded PNGs are pretty large.
Any suggestions?

Use drawNode to draw control buttons shape?

Or embed textures due to the buttons shape is simply. for example progress bar can use one 2x2 white texture, and embed arrow, stop textures

Add fullscreen enter and exit controls
setUserInputEnabled and isUserInputEnabled replaced by setMediaControllerEnabled and isMediaControllerEnabled
@rh101 rh101 marked this pull request as ready for review April 23, 2024 18:19
core/ui/UIMediaPlayer.cpp Outdated Show resolved Hide resolved
@halx99 halx99 added the enhancement New feature or request label Apr 24, 2024
@halx99 halx99 merged commit 3916a23 into axmolengine:dev Apr 24, 2024
14 of 15 checks passed
@rh101 rh101 deleted the generic-media-controller branch April 24, 2024 14:36
@halx99
Copy link
Collaborator

halx99 commented Apr 24, 2024

Hi @rh101
@asnagni said can't see controller buttons on iOS, could you take a look?
you can login to discord to view detail conversations

@rh101
Copy link
Contributor Author

rh101 commented Apr 24, 2024

Hi @rh101 @asnagni said can't see controller buttons on iOS, could you take a look? you can login to discord to view detail conversations

I'll load it up right now and check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request media
Projects
None yet
Development

Successfully merging this pull request may close these issues.

VideoPlayer controls buttons not showing
3 participants