Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 10966b7

Browse files
authored
[video_player_platform_interface] Add interface changes for audio mix mode (#2927)
1 parent 0d5dd3a commit 10966b7

File tree

5 files changed

+68
-2
lines changed

5 files changed

+68
-2
lines changed

packages/video_player/video_player_platform_interface/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.1.0
2+
3+
* Add VideoPlayerOptions with audo mix mode
4+
15
## 2.0.2
26

37
* Migrated tests to use pigeon correctly.

packages/video_player/video_player_platform_interface/lib/messages.dart

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Autogenerated from Pigeon (v0.1.0-experimental.10), do not edit directly.
1+
// Autogenerated from Pigeon (v0.1.0-experimental.11), do not edit directly.
22
// See also: https://pub.dev/packages/pigeon
33
// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import
44
import 'dart:async';
@@ -107,6 +107,23 @@ class PositionMessage {
107107
}
108108
}
109109

110+
class MixWithOthersMessage {
111+
bool mixWithOthers;
112+
// ignore: unused_element
113+
Map<dynamic, dynamic> _toMap() {
114+
final Map<dynamic, dynamic> pigeonMap = <dynamic, dynamic>{};
115+
pigeonMap['mixWithOthers'] = mixWithOthers;
116+
return pigeonMap;
117+
}
118+
119+
// ignore: unused_element
120+
static MixWithOthersMessage _fromMap(Map<dynamic, dynamic> pigeonMap) {
121+
final MixWithOthersMessage result = MixWithOthersMessage();
122+
result.mixWithOthers = pigeonMap['mixWithOthers'];
123+
return result;
124+
}
125+
}
126+
110127
abstract class VideoPlayerApiTest {
111128
void initialize();
112129
TextureMessage create(CreateMessage arg);
@@ -407,4 +424,27 @@ class VideoPlayerApi {
407424
// noop
408425
}
409426
}
427+
428+
Future<void> setMixWithOthers(MixWithOthersMessage arg) async {
429+
final Map<dynamic, dynamic> requestMap = arg._toMap();
430+
const BasicMessageChannel<dynamic> channel = BasicMessageChannel<dynamic>(
431+
'dev.flutter.pigeon.VideoPlayerApi.setMixWithOthers',
432+
StandardMessageCodec());
433+
434+
final Map<dynamic, dynamic> replyMap = await channel.send(requestMap);
435+
if (replyMap == null) {
436+
throw PlatformException(
437+
code: 'channel-error',
438+
message: 'Unable to establish connection on channel.',
439+
details: null);
440+
} else if (replyMap['error'] != null) {
441+
final Map<dynamic, dynamic> error = replyMap['error'];
442+
throw PlatformException(
443+
code: error['code'],
444+
message: error['message'],
445+
details: error['details']);
446+
} else {
447+
// noop
448+
}
449+
}
410450
}

packages/video_player/video_player_platform_interface/lib/method_channel_video_player.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,13 @@ class MethodChannelVideoPlayer extends VideoPlayerPlatform {
125125
return Texture(textureId: textureId);
126126
}
127127

128+
@override
129+
Future<void> setMixWithOthers(bool mixWithOthers) {
130+
return _api.setMixWithOthers(
131+
MixWithOthersMessage()..mixWithOthers = mixWithOthers,
132+
);
133+
}
134+
128135
EventChannel _eventChannelFor(int textureId) {
129136
return EventChannel('flutter.io/videoPlayer/videoEvents$textureId');
130137
}

packages/video_player/video_player_platform_interface/lib/video_player_platform_interface.dart

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@ abstract class VideoPlayerPlatform {
110110
throw UnimplementedError('buildView() has not been implemented.');
111111
}
112112

113+
/// Sets the audio mode to mix with other sources
114+
Future<void> setMixWithOthers(bool mixWithOthers) {
115+
throw UnimplementedError('setMixWithOthers() has not been implemented.');
116+
}
117+
113118
// This method makes sure that VideoPlayer isn't implemented with `implements`.
114119
//
115120
// See class doc for more details on why implementing this class is forbidden.
@@ -331,3 +336,13 @@ class DurationRange {
331336
@override
332337
int get hashCode => start.hashCode ^ end.hashCode;
333338
}
339+
340+
/// [VideoPlayerOptions] can be optionally used to set additional player settings
341+
class VideoPlayerOptions {
342+
/// Set this to true to mix the video players audio with other audio sources.
343+
/// The default value is false
344+
final bool mixWithOthers;
345+
346+
/// set additional optional player settings
347+
VideoPlayerOptions({this.mixWithOthers = false});
348+
}

packages/video_player/video_player_platform_interface/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: A common platform interface for the video_player plugin.
33
homepage: https://github.com/flutter/plugins/tree/master/packages/video_player/video_player_platform_interface
44
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
55
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
6-
version: 2.0.2
6+
version: 2.1.0
77

88
dependencies:
99
flutter:

0 commit comments

Comments
 (0)