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

Adds functionality to flet_video to know what song is playing #3772

Merged
merged 6 commits into from
Aug 8, 2024
Merged

Adds functionality to flet_video to know what song is playing #3772

merged 6 commits into from
Aug 8, 2024

Conversation

syleishere
Copy link
Contributor

@syleishere syleishere commented Aug 6, 2024

Description

Adds event on_track_changed to know current song index that is currently playing.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • [ x] New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [ x] This change requires a documentation update

Checklist:

  • [x ] I signed the CLA.

  • [ x] My code follows the style guidelines of this project

  • [ x] I have performed a self-review of my own code

  • [ x] I have commented my code, particularly in hard-to-understand areas

  • [ x] My changes generate no new warnings

  • [ x] New and existing tests pass locally with my changes

  • I have made corresponding changes to the documentation (if applicable)

Additional details

With this new feature you will always know what track currently is playing. Returns an Int of what number in your playlist is currently playing.

I will submit a PR to update documentation for this feature on website.

Summary by Sourcery

Introduce the on_track_changed event to flet_video to track the current song index in the playlist and update the documentation accordingly.

New Features:

  • Add on_track_changed event to track the current song index in the playlist.

Documentation:

  • Update documentation to include the new on_track_changed event feature.

Copy link
Contributor

sourcery-ai bot commented Aug 6, 2024

Reviewer's Guide by Sourcery

This pull request introduces a new feature to the flet_video package that allows the application to know which song is currently playing. The changes include adding a new event handler for track changes in both the Dart and Python parts of the codebase. The _onTrackChanged method and onTrackChanged attribute were added to the Dart code, while the on_track_changed parameter and corresponding getter and setter were added to the Python code. These changes ensure that the current track index is available and can be handled appropriately.

File-Level Changes

Files Changes
packages/flet_video/lib/src/video.dart
sdk/python/packages/flet-core/src/flet_core/video.py
Added functionality to handle track change events in the video player, including new methods, attributes, and event listeners.

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

Copy link
Contributor

@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.

Hey @syleishere - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 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 to tell me if it was helpful.

@@ -68,6 +68,12 @@ class _VideoControlState extends State<VideoControl> with FletStoreMixin {
.triggerControlEvent(widget.control.id, "completed", message ?? "");
}

void _onTrackChanged(String? message) {
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: Consider extracting a common method for event handling

The _onTrackChanged method is very similar to _onCompleted. Consider extracting a common method to handle these events, reducing code duplication and improving maintainability.

void _triggerControlEvent(String eventName, String? message) {
  debugPrint("Video $eventName: $message");
  widget.backend.triggerControlEvent(widget.control.id, eventName, message ?? "");
}

void _onTrackChanged(String? message) {
  _triggerControlEvent("trackChanged", message);
}

Copy link
Contributor Author

@syleishere syleishere left a comment

Choose a reason for hiding this comment

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

Done

@FeodorFitsner FeodorFitsner merged commit a30915f into flet-dev:main Aug 8, 2024
2 checks 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