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

support for custom text property for a subtitle #480

Merged
merged 8 commits into from
Jun 14, 2021

Conversation

ekuleshov
Copy link
Contributor

Support for custom RichText subtitles #479

lib/src/chewie_player.dart Outdated Show resolved Hide resolved
lib/src/cupertino/cupertino_controls.dart Outdated Show resolved Hide resolved
lib/src/material/material_controls.dart Outdated Show resolved Hide resolved
lib/src/material/material_desktop_controls.dart Outdated Show resolved Hide resolved
lib/src/models/subtitle_model.dart Show resolved Hide resolved
@Ahmadre Ahmadre changed the title support for custom RichText subtitles support for custom text property for a subtitle Jun 1, 2021
@Ahmadre
Copy link
Collaborator

Ahmadre commented Jun 1, 2021

Thank you @ekuleshov for your PR!

@ekuleshov
Copy link
Contributor Author

Thank you @ekuleshov for your PR!

You may want to reopen #479

@ekuleshov
Copy link
Contributor Author

ekuleshov commented Jun 4, 2021

@Ahmadre I tried to change Subtitles and subtitleBuilder to be parametrized types like:

class Subtitles<T> {
  Subtitles(this.subtitle, { this.subtitleBuilder });

  final List<Subtitle<T>?> subtitle;
  Widget Function(BuildContext context, T subtitle)? subtitleBuilder;
  ...

The subtitle and subtitleBuilder values need to be tied together because of a common generic type, in under Subtitles class (which is basically a Typle) stored in the ChewieController instance.

Unfortunately I could not make generic types work. Getting a type case issue at runtime even without is and as.

Now I'm not sure if it is the best way to approach this.

Or perhaps maybe the subtitleBuilder could be changed to take in a Subtitle instance instead of a String. Then I could extend Subtitle class with my own fields and will be able to do my own type casting in the subtitleBulder implementation.

What do you think?

ekuleshov added 2 commits June 3, 2021 22:12
…builder

# Conflicts:
#	example/lib/app/app.dart
#	lib/src/chewie_player.dart
#	lib/src/cupertino/cupertino_controls.dart
@Ahmadre
Copy link
Collaborator

Ahmadre commented Jun 5, 2021

@Ahmadre I tried to change Subtitles and subtitleBuilder to be parametrized types like:


class Subtitles<T> {

  Subtitles(this.subtitle, { this.subtitleBuilder });



  final List<Subtitle<T>?> subtitle;

  Widget Function(BuildContext context, T subtitle)? subtitleBuilder;

  ...

The subtitle and subtitleBuilder values need to be tied together because of a common generic type, in under Subtitles class (which is basically a Typle) stored in the ChewieController instance.

Unfortunately I could not make generic types work. Getting a type case issue at runtime even without is and as.

Now I'm not sure if it is the best way to approach this.

Or perhaps maybe the subtitleBuilder could be changed to take in a Subtitle instance instead of a String. Then I could extend Subtitle class with my own fields and will be able to do my own type casting in the subtitleBulder implementation.

What do you think?

thank you for your suggestions. I will have a look at it the next week. I'm on vacation :D

@Ahmadre
Copy link
Collaborator

Ahmadre commented Jun 13, 2021

LGTM @ekuleshov :) Could you please update your branch with the latest master? After that I would merge this! I really like it and I think this way we got much more flexibility!

And could you check the CI-build errors and correct them in your branch?

@Ahmadre Ahmadre linked an issue Jun 13, 2021 that may be closed by this pull request
@ekuleshov
Copy link
Contributor Author

LGTM

Which part? Like I said, I could not make generified variant work.

A variant with extending Subtitle turned out rather ugly. Personally I'd have preferred a variant with dynamic text.

@ekuleshov ekuleshov removed their assignment Jun 14, 2021
@ekuleshov
Copy link
Contributor Author

It seems like to make subtitles to use generic value instead of String will require generic type all the way up to the Chewie widget.

All in all, it seems like coupling subtitles into every video control implementation is too restrictive. It would be better to decouple subtitles from that and use a separate widget overlay instead. Somewhat similar to what subtitle_wrapper_package does. Then generic type only need to be specified when configuring subtitles overlay.

@ekuleshov ekuleshov closed this Jun 14, 2021
@Ahmadre Ahmadre reopened this Jun 14, 2021
@Ahmadre
Copy link
Collaborator

Ahmadre commented Jun 14, 2021

I meant the actual changes with dynamic looks good!

We can do that like in the first step.

…builder

# Conflicts:
#	example/lib/app/app.dart
#	lib/src/chewie_player.dart
#	lib/src/cupertino/cupertino_controls.dart
#	lib/src/material/material_controls.dart
#	lib/src/material/material_desktop_controls.dart
#	lib/src/models/subtitle_model.dart
@ekuleshov
Copy link
Contributor Author

We can do that like in the first step.

@Ahmadre okay. I re-did the variant with dynamic type. Please review

@Ahmadre Ahmadre merged commit 94d4e71 into fluttercommunity:master Jun 14, 2021
@ekuleshov
Copy link
Contributor Author

@Ahmadre do you have a timeline on getting this change into a plugin release?

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.

support custom RichText subtitles
2 participants