Skip to content

Commit d4750ea

Browse files
author
Chris Yang
authored
Revert "[video_player] Set audio mix options (flutter#2922)" (flutter#2938)
This reverts commit 77fbfcd.
1 parent 0e46769 commit d4750ea

File tree

13 files changed

+12
-166
lines changed

13 files changed

+12
-166
lines changed

packages/video_player/video_player/CHANGELOG.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
## 0.10.12
2-
3-
* Introduce VideoPlayerOptions to set the audio mix mode.
4-
51
## 0.10.11+2
62

73
* Fix aspectRatio calculation when size.width or size.height are zero.

packages/video_player/video_player/android/src/main/java/io/flutter/plugins/videoplayer/Messages.java

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -223,31 +223,6 @@ static PositionMessage fromMap(HashMap map) {
223223
}
224224
}
225225

226-
/** Generated class from Pigeon that represents data sent in messages. */
227-
public static class MixWithOthersMessage {
228-
private Boolean mixWithOthers;
229-
230-
public Boolean getMixWithOthers() {
231-
return mixWithOthers;
232-
}
233-
234-
public void setMixWithOthers(Boolean setterArg) {
235-
this.mixWithOthers = setterArg;
236-
}
237-
238-
HashMap toMap() {
239-
HashMap<String, Object> toMapResult = new HashMap<String, Object>();
240-
toMapResult.put("mixWithOthers", mixWithOthers);
241-
return toMapResult;
242-
}
243-
244-
static MixWithOthersMessage fromMap(HashMap map) {
245-
MixWithOthersMessage fromMapResult = new MixWithOthersMessage();
246-
fromMapResult.mixWithOthers = (Boolean) map.get("mixWithOthers");
247-
return fromMapResult;
248-
}
249-
}
250-
251226
/** Generated interface from Pigeon that represents a handler of messages from Flutter. */
252227
public interface VideoPlayerApi {
253228
void initialize();
@@ -268,8 +243,6 @@ public interface VideoPlayerApi {
268243

269244
void pause(TextureMessage arg);
270245

271-
void setMixWithOthers(MixWithOthersMessage arg);
272-
273246
/** Sets up an instance of `VideoPlayerApi` to handle messages through the `binaryMessenger` */
274247
public static void setup(BinaryMessenger binaryMessenger, VideoPlayerApi api) {
275248
{
@@ -496,31 +469,6 @@ public void onMessage(Object message, BasicMessageChannel.Reply<Object> reply) {
496469
channel.setMessageHandler(null);
497470
}
498471
}
499-
{
500-
BasicMessageChannel<Object> channel =
501-
new BasicMessageChannel<Object>(
502-
binaryMessenger,
503-
"dev.flutter.pigeon.VideoPlayerApi.setMixWithOthers",
504-
new StandardMessageCodec());
505-
if (api != null) {
506-
channel.setMessageHandler(
507-
new BasicMessageChannel.MessageHandler<Object>() {
508-
public void onMessage(Object message, BasicMessageChannel.Reply<Object> reply) {
509-
MixWithOthersMessage input = MixWithOthersMessage.fromMap((HashMap) message);
510-
HashMap<String, HashMap> wrapped = new HashMap<String, HashMap>();
511-
try {
512-
api.setMixWithOthers(input);
513-
wrapped.put("result", null);
514-
} catch (Exception exception) {
515-
wrapped.put("error", wrapError(exception));
516-
}
517-
reply.reply(wrapped);
518-
}
519-
});
520-
} else {
521-
channel.setMessageHandler(null);
522-
}
523-
}
524472
}
525473
}
526474

packages/video_player/video_player/android/src/main/java/io/flutter/plugins/videoplayer/VideoPlayer.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,14 @@ final class VideoPlayer {
5656

5757
private boolean isInitialized = false;
5858

59-
private final VideoPlayerOptions options;
60-
6159
VideoPlayer(
6260
Context context,
6361
EventChannel eventChannel,
6462
TextureRegistry.SurfaceTextureEntry textureEntry,
6563
String dataSource,
66-
String formatHint,
67-
VideoPlayerOptions options) {
64+
String formatHint) {
6865
this.eventChannel = eventChannel;
6966
this.textureEntry = textureEntry;
70-
this.options = options;
7167

7268
TrackSelector trackSelector = new DefaultTrackSelector();
7369
exoPlayer = ExoPlayerFactory.newSimpleInstance(context, trackSelector);
@@ -167,7 +163,7 @@ public void onCancel(Object o) {
167163

168164
surface = new Surface(textureEntry.surfaceTexture());
169165
exoPlayer.setVideoSurface(surface);
170-
setAudioAttributes(exoPlayer, options.mixWithOthers);
166+
setAudioAttributes(exoPlayer);
171167

172168
exoPlayer.addListener(
173169
new EventListener() {
@@ -207,10 +203,10 @@ void sendBufferingUpdate() {
207203
}
208204

209205
@SuppressWarnings("deprecation")
210-
private static void setAudioAttributes(SimpleExoPlayer exoPlayer, boolean isMixMode) {
206+
private static void setAudioAttributes(SimpleExoPlayer exoPlayer) {
211207
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
212208
exoPlayer.setAudioAttributes(
213-
new AudioAttributes.Builder().setContentType(C.CONTENT_TYPE_MOVIE).build(), !isMixMode);
209+
new AudioAttributes.Builder().setContentType(C.CONTENT_TYPE_MOVIE).build());
214210
} else {
215211
exoPlayer.setAudioStreamType(C.STREAM_TYPE_MUSIC);
216212
}

packages/video_player/video_player/android/src/main/java/io/flutter/plugins/videoplayer/VideoPlayerOptions.java

Lines changed: 0 additions & 5 deletions
This file was deleted.

packages/video_player/video_player/android/src/main/java/io/flutter/plugins/videoplayer/VideoPlayerPlugin.java

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import io.flutter.plugin.common.PluginRegistry.Registrar;
1414
import io.flutter.plugins.videoplayer.Messages.CreateMessage;
1515
import io.flutter.plugins.videoplayer.Messages.LoopingMessage;
16-
import io.flutter.plugins.videoplayer.Messages.MixWithOthersMessage;
1716
import io.flutter.plugins.videoplayer.Messages.PositionMessage;
1817
import io.flutter.plugins.videoplayer.Messages.TextureMessage;
1918
import io.flutter.plugins.videoplayer.Messages.VideoPlayerApi;
@@ -26,7 +25,6 @@ public class VideoPlayerPlugin implements FlutterPlugin, VideoPlayerApi {
2625
private static final String TAG = "VideoPlayerPlugin";
2726
private final LongSparseArray<VideoPlayer> videoPlayers = new LongSparseArray<>();
2827
private FlutterState flutterState;
29-
private VideoPlayerOptions options = new VideoPlayerOptions();
3028

3129
/** Register this with the v2 embedding for the plugin to respond to lifecycle callbacks. */
3230
public VideoPlayerPlugin() {}
@@ -115,8 +113,7 @@ public TextureMessage create(CreateMessage arg) {
115113
eventChannel,
116114
handle,
117115
"asset:///" + assetLookupKey,
118-
null,
119-
options);
116+
null);
120117
videoPlayers.put(handle.id(), player);
121118
} else {
122119
player =
@@ -125,8 +122,7 @@ public TextureMessage create(CreateMessage arg) {
125122
eventChannel,
126123
handle,
127124
arg.getUri(),
128-
arg.getFormatHint(),
129-
options);
125+
arg.getFormatHint());
130126
videoPlayers.put(handle.id(), player);
131127
}
132128

@@ -174,11 +170,6 @@ public void pause(TextureMessage arg) {
174170
player.pause();
175171
}
176172

177-
@Override
178-
public void setMixWithOthers(MixWithOthersMessage arg) {
179-
options.mixWithOthers = arg.getMixWithOthers();
180-
}
181-
182173
private interface KeyForAssetFn {
183174
String get(String asset);
184175
}

packages/video_player/video_player/example/lib/main.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ class _BumbleBeeRemoteVideoState extends State<_BumbleBeeRemoteVideo> {
220220
_controller = VideoPlayerController.network(
221221
'https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4',
222222
closedCaptionFile: _loadCaptions(),
223-
videoPlayerOptions: VideoPlayerOptions(mixWithOthers: true),
224223
);
225224

226225
_controller.addListener(() {

packages/video_player/video_player/ios/Classes/FLTVideoPlayerPlugin.m

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -560,15 +560,4 @@ - (void)pause:(FLTTextureMessage*)input error:(FlutterError**)error {
560560
[player pause];
561561
}
562562

563-
- (void)setMixWithOthers:(FLTMixWithOthersMessage*)input
564-
error:(FlutterError* _Nullable __autoreleasing*)error {
565-
if ([input.mixWithOthers boolValue]) {
566-
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback
567-
withOptions:AVAudioSessionCategoryOptionMixWithOthers
568-
error:nil];
569-
} else {
570-
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
571-
}
572-
}
573-
574563
@end

packages/video_player/video_player/ios/Classes/messages.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ NS_ASSUME_NONNULL_BEGIN
1212
@class FLTLoopingMessage;
1313
@class FLTVolumeMessage;
1414
@class FLTPositionMessage;
15-
@class FLTMixWithOthersMessage;
1615

1716
@interface FLTTextureMessage : NSObject
1817
@property(nonatomic, strong, nullable) NSNumber *textureId;
@@ -40,10 +39,6 @@ NS_ASSUME_NONNULL_BEGIN
4039
@property(nonatomic, strong, nullable) NSNumber *position;
4140
@end
4241

43-
@interface FLTMixWithOthersMessage : NSObject
44-
@property(nonatomic, strong, nullable) NSNumber *mixWithOthers;
45-
@end
46-
4742
@protocol FLTVideoPlayerApi
4843
- (void)initialize:(FlutterError *_Nullable *_Nonnull)error;
4944
- (nullable FLTTextureMessage *)create:(FLTCreateMessage *)input
@@ -56,8 +51,6 @@ NS_ASSUME_NONNULL_BEGIN
5651
error:(FlutterError *_Nullable *_Nonnull)error;
5752
- (void)seekTo:(FLTPositionMessage *)input error:(FlutterError *_Nullable *_Nonnull)error;
5853
- (void)pause:(FLTTextureMessage *)input error:(FlutterError *_Nullable *_Nonnull)error;
59-
- (void)setMixWithOthers:(FLTMixWithOthersMessage *)input
60-
error:(FlutterError *_Nullable *_Nonnull)error;
6154
@end
6255

6356
extern void FLTVideoPlayerApiSetup(id<FlutterBinaryMessenger> binaryMessenger,

packages/video_player/video_player/ios/Classes/messages.m

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@ @interface FLTPositionMessage ()
4040
+ (FLTPositionMessage *)fromMap:(NSDictionary *)dict;
4141
- (NSDictionary *)toMap;
4242
@end
43-
@interface FLTMixWithOthersMessage ()
44-
+ (FLTMixWithOthersMessage *)fromMap:(NSDictionary *)dict;
45-
- (NSDictionary *)toMap;
46-
@end
4743

4844
@implementation FLTTextureMessage
4945
+ (FLTTextureMessage *)fromMap:(NSDictionary *)dict {
@@ -158,22 +154,6 @@ - (NSDictionary *)toMap {
158154
}
159155
@end
160156

161-
@implementation FLTMixWithOthersMessage
162-
+ (FLTMixWithOthersMessage *)fromMap:(NSDictionary *)dict {
163-
FLTMixWithOthersMessage *result = [[FLTMixWithOthersMessage alloc] init];
164-
result.mixWithOthers = dict[@"mixWithOthers"];
165-
if ((NSNull *)result.mixWithOthers == [NSNull null]) {
166-
result.mixWithOthers = nil;
167-
}
168-
return result;
169-
}
170-
- (NSDictionary *)toMap {
171-
return [NSDictionary
172-
dictionaryWithObjectsAndKeys:(self.mixWithOthers != nil ? self.mixWithOthers : [NSNull null]),
173-
@"mixWithOthers", nil];
174-
}
175-
@end
176-
177157
void FLTVideoPlayerApiSetup(id<FlutterBinaryMessenger> binaryMessenger, id<FLTVideoPlayerApi> api) {
178158
{
179159
FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel
@@ -309,19 +289,4 @@ void FLTVideoPlayerApiSetup(id<FlutterBinaryMessenger> binaryMessenger, id<FLTVi
309289
[channel setMessageHandler:nil];
310290
}
311291
}
312-
{
313-
FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel
314-
messageChannelWithName:@"dev.flutter.pigeon.VideoPlayerApi.setMixWithOthers"
315-
binaryMessenger:binaryMessenger];
316-
if (api) {
317-
[channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
318-
FlutterError *error;
319-
FLTMixWithOthersMessage *input = [FLTMixWithOthersMessage fromMap:message];
320-
[api setMixWithOthers:input error:&error];
321-
callback(wrapResult(nil, error));
322-
}];
323-
} else {
324-
[channel setMessageHandler:nil];
325-
}
326-
}
327292
}

packages/video_player/video_player/lib/video_player.dart

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import 'package:meta/meta.dart';
1212

1313
import 'package:video_player_platform_interface/video_player_platform_interface.dart';
1414
export 'package:video_player_platform_interface/video_player_platform_interface.dart'
15-
show DurationRange, DataSourceType, VideoFormat, VideoPlayerOptions;
15+
show DurationRange, DataSourceType, VideoFormat;
1616

1717
import 'src/closed_caption_file.dart';
1818
export 'src/closed_caption_file.dart';
@@ -168,7 +168,7 @@ class VideoPlayerController extends ValueNotifier<VideoPlayerValue> {
168168
/// null. The [package] argument must be non-null when the asset comes from a
169169
/// package and null otherwise.
170170
VideoPlayerController.asset(this.dataSource,
171-
{this.package, this.closedCaptionFile, this.videoPlayerOptions})
171+
{this.package, this.closedCaptionFile})
172172
: dataSourceType = DataSourceType.asset,
173173
formatHint = null,
174174
super(VideoPlayerValue(duration: null));
@@ -181,7 +181,7 @@ class VideoPlayerController extends ValueNotifier<VideoPlayerValue> {
181181
/// **Android only**: The [formatHint] option allows the caller to override
182182
/// the video format detection code.
183183
VideoPlayerController.network(this.dataSource,
184-
{this.formatHint, this.closedCaptionFile, this.videoPlayerOptions})
184+
{this.formatHint, this.closedCaptionFile})
185185
: dataSourceType = DataSourceType.network,
186186
package = null,
187187
super(VideoPlayerValue(duration: null));
@@ -190,8 +190,7 @@ class VideoPlayerController extends ValueNotifier<VideoPlayerValue> {
190190
///
191191
/// This will load the file from the file-URI given by:
192192
/// `'file://${file.path}'`.
193-
VideoPlayerController.file(File file,
194-
{this.closedCaptionFile, this.videoPlayerOptions})
193+
VideoPlayerController.file(File file, {this.closedCaptionFile})
195194
: dataSource = 'file://${file.path}',
196195
dataSourceType = DataSourceType.file,
197196
package = null,
@@ -212,9 +211,6 @@ class VideoPlayerController extends ValueNotifier<VideoPlayerValue> {
212211
/// is constructed with.
213212
final DataSourceType dataSourceType;
214213

215-
/// Provide additional configuration options (optional). Like setting the audio mode to mix
216-
final VideoPlayerOptions videoPlayerOptions;
217-
218214
/// Only set for [asset] videos. The package that the asset was loaded from.
219215
final String package;
220216

@@ -266,12 +262,6 @@ class VideoPlayerController extends ValueNotifier<VideoPlayerValue> {
266262
);
267263
break;
268264
}
269-
270-
if (videoPlayerOptions?.mixWithOthers != null) {
271-
await _videoPlayerPlatform
272-
.setMixWithOthers(videoPlayerOptions.mixWithOthers);
273-
}
274-
275265
_textureId = await _videoPlayerPlatform.create(dataSourceDescription);
276266
_creatingCompleter.complete(null);
277267
final Completer<void> initializingCompleter = Completer<void>();

packages/video_player/video_player/pigeons/messages.dart

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@ class CreateMessage {
2626
String formatHint;
2727
}
2828

29-
class MixWithOthersMessage {
30-
bool mixWithOthers;
31-
}
32-
3329
@HostApi()
3430
abstract class VideoPlayerApi {
3531
void initialize();
@@ -41,7 +37,6 @@ abstract class VideoPlayerApi {
4137
PositionMessage position(TextureMessage msg);
4238
void seekTo(PositionMessage msg);
4339
void pause(TextureMessage msg);
44-
void setMixWithOthers(MixWithOthersMessage msg);
4540
}
4641

4742
void configurePigeon(PigeonOptions opts) {

packages/video_player/video_player/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Flutter plugin for displaying inline video with other Flutter
44
# 0.10.y+z is compatible with 1.0.0, if you land a breaking change bump
55
# the version to 2.0.0.
66
# See more details: https://github.com/flutter/flutter/wiki/Package-migration-to-1.0.0
7-
version: 0.10.12
7+
version: 0.10.11+2
88
homepage: https://github.com/flutter/plugins/tree/master/packages/video_player/video_player
99

1010
flutter:

0 commit comments

Comments
 (0)