Skip to content

[video_player] Adding support for preferred audio language #8980

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

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/video_player/video_player/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.9.6

* Adds support for preferred audio language in video_player if platform supports it.

## 2.9.5

* Fixes layout issue caused by `Transform.rotate` not affecting space calculation.
Expand Down Expand Up @@ -629,7 +633,7 @@ DefaultHttpDataSourceFactory by default.
## 0.9.0

* Fixed the aspect ratio and orientation of videos. Videos are now properly displayed when recorded
in portrait mode both in iOS and Android.
in portrait mode both in iOS and Android.

## 0.8.0

Expand Down
4 changes: 4 additions & 0 deletions packages/video_player/video_player/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,7 @@ flutter:
- assets/bumble_bee_captions.srt
- assets/bumble_bee_captions.vtt
- assets/Audio.mp3
# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE.
# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins
dependency_overrides:
video_player_platform_interface: {path: ../../../../packages/video_player/video_player_platform_interface}
11 changes: 11 additions & 0 deletions packages/video_player/video_player/lib/video_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,11 @@ class VideoPlayerController extends ValueNotifier<VideoPlayerValue> {
.setMixWithOthers(videoPlayerOptions!.mixWithOthers);
}

if (videoPlayerOptions?.preferredAudioLanguage != null) {
await _videoPlayerPlatform.setPreferredAudioLanguage(
videoPlayerOptions!.preferredAudioLanguage);
}

_textureId = (await _videoPlayerPlatform.create(dataSourceDescription)) ??
kUninitializedTextureId;
_creatingCompleter!.complete(null);
Expand Down Expand Up @@ -787,6 +792,12 @@ class VideoPlayerController extends ValueNotifier<VideoPlayerValue> {
}
}

/// Sets preferred audio language
Future<void> setPreferredAudioLanguage(String? preferredAudioLanguage) {
return _videoPlayerPlatform
.setPreferredAudioLanguage(preferredAudioLanguage);
}

bool get _isDisposedOrNotInitialized => _isDisposed || !value.isInitialized;
}

Expand Down
4 changes: 4 additions & 0 deletions packages/video_player/video_player/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,7 @@ dev_dependencies:
topics:
- video
- video-player
# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE.
# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins
dependency_overrides:
video_player_platform_interface: {path: ../../../packages/video_player/video_player_platform_interface}
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ class FakeController extends ValueNotifier<VideoPlayerValue>
Future<void> setClosedCaptionFile(
Future<ClosedCaptionFile>? closedCaptionFile,
) async {}

@override
Future<void> setPreferredAudioLanguage(String? preferredAudioLanguage) async {}
}

Future<ClosedCaptionFile> _loadClosedCaption() async =>
Expand Down
4 changes: 4 additions & 0 deletions packages/video_player/video_player_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.8.3

* Adds support for preferred audio language by passing preferredAudioLanguage string parameter (for example 'en' or 'fr') via VideoPlayerOptions when initializing VideoPlayerController.

## 2.8.2

* Fixes a [bug](https://github.com/flutter/flutter/issues/164689) that can cause video to
Expand Down
Loading