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 frame step buttons to internal video player #1207

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ecawthorne
Copy link

Hi! This PR is based on #716. It adds an option for stepping through videos approximately frame by frame.

The setting is disabled by default and the new buttons are grayed out and disabled when playing as per this comment #716 (comment) by @QuantumBadger

Thanks! This looks good to me, when I get a chance I'll test/merge it and maybe add new icons.

I think it would be good to keep the new buttons hidden by default and have a preference to enable them, but I'm happy to do this if it's not clear how.

It might also be worth greying out the buttons while the video isn't paused (which may require another set of icons in a different colour).

I apologize if I'm stepping on any toes, there's been no activity on #716 for over a year so I figured I'd pick it up. Any feedback or suggestions are very welcome if there's more that needs to be done.

Created icon_restart in order to reuse icon_previous asset for the
frame step back button
@ecawthorne ecawthorne changed the title Add frame step buttons to interal video player Add frame step buttons to internal video player Jul 15, 2024
R.string.video_step_back,
view -> {
long frameRate = mVideoPlayer.getVideoFormat() != null ? 30 : (long) mVideoPlayer.getVideoFormat().frameRate;
mVideoPlayer.seekTo(mVideoPlayer.getCurrentPosition() - frameRate);
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this is the correct way to do it? Frame rate is a number of frames in a second so you need to calculate 1000 / frameRate to get duration of a frame in milliseconds

Copy link
Author

@ecawthorne ecawthorne Sep 5, 2024

Choose a reason for hiding this comment

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

You're absolutely right, I'm not sure what I was thinking there. I also unintentionally inverted the null check which hid a different issue: apparently getVideoFormat().framerate is always null in this context. After looking into it a bit, it seems like it's due to the format being H.264/AVC which ExoPlayer doesn't supply a frame rate for.

The condition is fixed in 8e0efb3. If you have any suggestions on how to proceed for calculating the frame rate just let me know. I'm working on the assumption that there may be a format change at some point in the future so I kept the frame rate check there for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants