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

Commit

Permalink
Revert "[video_player] Set audio mix options (#2922)" (#2938)
Browse files Browse the repository at this point in the history
This reverts commit 77fbfcd.
  • Loading branch information
Chris Yang authored Aug 18, 2020
1 parent 0e46769 commit d4750ea
Show file tree
Hide file tree
Showing 13 changed files with 12 additions and 166 deletions.
4 changes: 0 additions & 4 deletions packages/video_player/video_player/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
## 0.10.12

* Introduce VideoPlayerOptions to set the audio mix mode.

## 0.10.11+2

* Fix aspectRatio calculation when size.width or size.height are zero.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,31 +223,6 @@ static PositionMessage fromMap(HashMap map) {
}
}

/** Generated class from Pigeon that represents data sent in messages. */
public static class MixWithOthersMessage {
private Boolean mixWithOthers;

public Boolean getMixWithOthers() {
return mixWithOthers;
}

public void setMixWithOthers(Boolean setterArg) {
this.mixWithOthers = setterArg;
}

HashMap toMap() {
HashMap<String, Object> toMapResult = new HashMap<String, Object>();
toMapResult.put("mixWithOthers", mixWithOthers);
return toMapResult;
}

static MixWithOthersMessage fromMap(HashMap map) {
MixWithOthersMessage fromMapResult = new MixWithOthersMessage();
fromMapResult.mixWithOthers = (Boolean) map.get("mixWithOthers");
return fromMapResult;
}
}

/** Generated interface from Pigeon that represents a handler of messages from Flutter. */
public interface VideoPlayerApi {
void initialize();
Expand All @@ -268,8 +243,6 @@ public interface VideoPlayerApi {

void pause(TextureMessage arg);

void setMixWithOthers(MixWithOthersMessage arg);

/** Sets up an instance of `VideoPlayerApi` to handle messages through the `binaryMessenger` */
public static void setup(BinaryMessenger binaryMessenger, VideoPlayerApi api) {
{
Expand Down Expand Up @@ -496,31 +469,6 @@ public void onMessage(Object message, BasicMessageChannel.Reply<Object> reply) {
channel.setMessageHandler(null);
}
}
{
BasicMessageChannel<Object> channel =
new BasicMessageChannel<Object>(
binaryMessenger,
"dev.flutter.pigeon.VideoPlayerApi.setMixWithOthers",
new StandardMessageCodec());
if (api != null) {
channel.setMessageHandler(
new BasicMessageChannel.MessageHandler<Object>() {
public void onMessage(Object message, BasicMessageChannel.Reply<Object> reply) {
MixWithOthersMessage input = MixWithOthersMessage.fromMap((HashMap) message);
HashMap<String, HashMap> wrapped = new HashMap<String, HashMap>();
try {
api.setMixWithOthers(input);
wrapped.put("result", null);
} catch (Exception exception) {
wrapped.put("error", wrapError(exception));
}
reply.reply(wrapped);
}
});
} else {
channel.setMessageHandler(null);
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,14 @@ final class VideoPlayer {

private boolean isInitialized = false;

private final VideoPlayerOptions options;

VideoPlayer(
Context context,
EventChannel eventChannel,
TextureRegistry.SurfaceTextureEntry textureEntry,
String dataSource,
String formatHint,
VideoPlayerOptions options) {
String formatHint) {
this.eventChannel = eventChannel;
this.textureEntry = textureEntry;
this.options = options;

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

surface = new Surface(textureEntry.surfaceTexture());
exoPlayer.setVideoSurface(surface);
setAudioAttributes(exoPlayer, options.mixWithOthers);
setAudioAttributes(exoPlayer);

exoPlayer.addListener(
new EventListener() {
Expand Down Expand Up @@ -207,10 +203,10 @@ void sendBufferingUpdate() {
}

@SuppressWarnings("deprecation")
private static void setAudioAttributes(SimpleExoPlayer exoPlayer, boolean isMixMode) {
private static void setAudioAttributes(SimpleExoPlayer exoPlayer) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
exoPlayer.setAudioAttributes(
new AudioAttributes.Builder().setContentType(C.CONTENT_TYPE_MOVIE).build(), !isMixMode);
new AudioAttributes.Builder().setContentType(C.CONTENT_TYPE_MOVIE).build());
} else {
exoPlayer.setAudioStreamType(C.STREAM_TYPE_MUSIC);
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import io.flutter.plugin.common.PluginRegistry.Registrar;
import io.flutter.plugins.videoplayer.Messages.CreateMessage;
import io.flutter.plugins.videoplayer.Messages.LoopingMessage;
import io.flutter.plugins.videoplayer.Messages.MixWithOthersMessage;
import io.flutter.plugins.videoplayer.Messages.PositionMessage;
import io.flutter.plugins.videoplayer.Messages.TextureMessage;
import io.flutter.plugins.videoplayer.Messages.VideoPlayerApi;
Expand All @@ -26,7 +25,6 @@ public class VideoPlayerPlugin implements FlutterPlugin, VideoPlayerApi {
private static final String TAG = "VideoPlayerPlugin";
private final LongSparseArray<VideoPlayer> videoPlayers = new LongSparseArray<>();
private FlutterState flutterState;
private VideoPlayerOptions options = new VideoPlayerOptions();

/** Register this with the v2 embedding for the plugin to respond to lifecycle callbacks. */
public VideoPlayerPlugin() {}
Expand Down Expand Up @@ -115,8 +113,7 @@ public TextureMessage create(CreateMessage arg) {
eventChannel,
handle,
"asset:///" + assetLookupKey,
null,
options);
null);
videoPlayers.put(handle.id(), player);
} else {
player =
Expand All @@ -125,8 +122,7 @@ public TextureMessage create(CreateMessage arg) {
eventChannel,
handle,
arg.getUri(),
arg.getFormatHint(),
options);
arg.getFormatHint());
videoPlayers.put(handle.id(), player);
}

Expand Down Expand Up @@ -174,11 +170,6 @@ public void pause(TextureMessage arg) {
player.pause();
}

@Override
public void setMixWithOthers(MixWithOthersMessage arg) {
options.mixWithOthers = arg.getMixWithOthers();
}

private interface KeyForAssetFn {
String get(String asset);
}
Expand Down
1 change: 0 additions & 1 deletion packages/video_player/video_player/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ class _BumbleBeeRemoteVideoState extends State<_BumbleBeeRemoteVideo> {
_controller = VideoPlayerController.network(
'https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4',
closedCaptionFile: _loadCaptions(),
videoPlayerOptions: VideoPlayerOptions(mixWithOthers: true),
);

_controller.addListener(() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -560,15 +560,4 @@ - (void)pause:(FLTTextureMessage*)input error:(FlutterError**)error {
[player pause];
}

- (void)setMixWithOthers:(FLTMixWithOthersMessage*)input
error:(FlutterError* _Nullable __autoreleasing*)error {
if ([input.mixWithOthers boolValue]) {
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback
withOptions:AVAudioSessionCategoryOptionMixWithOthers
error:nil];
} else {
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
}
}

@end
7 changes: 0 additions & 7 deletions packages/video_player/video_player/ios/Classes/messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ NS_ASSUME_NONNULL_BEGIN
@class FLTLoopingMessage;
@class FLTVolumeMessage;
@class FLTPositionMessage;
@class FLTMixWithOthersMessage;

@interface FLTTextureMessage : NSObject
@property(nonatomic, strong, nullable) NSNumber *textureId;
Expand Down Expand Up @@ -40,10 +39,6 @@ NS_ASSUME_NONNULL_BEGIN
@property(nonatomic, strong, nullable) NSNumber *position;
@end

@interface FLTMixWithOthersMessage : NSObject
@property(nonatomic, strong, nullable) NSNumber *mixWithOthers;
@end

@protocol FLTVideoPlayerApi
- (void)initialize:(FlutterError *_Nullable *_Nonnull)error;
- (nullable FLTTextureMessage *)create:(FLTCreateMessage *)input
Expand All @@ -56,8 +51,6 @@ NS_ASSUME_NONNULL_BEGIN
error:(FlutterError *_Nullable *_Nonnull)error;
- (void)seekTo:(FLTPositionMessage *)input error:(FlutterError *_Nullable *_Nonnull)error;
- (void)pause:(FLTTextureMessage *)input error:(FlutterError *_Nullable *_Nonnull)error;
- (void)setMixWithOthers:(FLTMixWithOthersMessage *)input
error:(FlutterError *_Nullable *_Nonnull)error;
@end

extern void FLTVideoPlayerApiSetup(id<FlutterBinaryMessenger> binaryMessenger,
Expand Down
35 changes: 0 additions & 35 deletions packages/video_player/video_player/ios/Classes/messages.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ @interface FLTPositionMessage ()
+ (FLTPositionMessage *)fromMap:(NSDictionary *)dict;
- (NSDictionary *)toMap;
@end
@interface FLTMixWithOthersMessage ()
+ (FLTMixWithOthersMessage *)fromMap:(NSDictionary *)dict;
- (NSDictionary *)toMap;
@end

@implementation FLTTextureMessage
+ (FLTTextureMessage *)fromMap:(NSDictionary *)dict {
Expand Down Expand Up @@ -158,22 +154,6 @@ - (NSDictionary *)toMap {
}
@end

@implementation FLTMixWithOthersMessage
+ (FLTMixWithOthersMessage *)fromMap:(NSDictionary *)dict {
FLTMixWithOthersMessage *result = [[FLTMixWithOthersMessage alloc] init];
result.mixWithOthers = dict[@"mixWithOthers"];
if ((NSNull *)result.mixWithOthers == [NSNull null]) {
result.mixWithOthers = nil;
}
return result;
}
- (NSDictionary *)toMap {
return [NSDictionary
dictionaryWithObjectsAndKeys:(self.mixWithOthers != nil ? self.mixWithOthers : [NSNull null]),
@"mixWithOthers", nil];
}
@end

void FLTVideoPlayerApiSetup(id<FlutterBinaryMessenger> binaryMessenger, id<FLTVideoPlayerApi> api) {
{
FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel
Expand Down Expand Up @@ -309,19 +289,4 @@ void FLTVideoPlayerApiSetup(id<FlutterBinaryMessenger> binaryMessenger, id<FLTVi
[channel setMessageHandler:nil];
}
}
{
FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel
messageChannelWithName:@"dev.flutter.pigeon.VideoPlayerApi.setMixWithOthers"
binaryMessenger:binaryMessenger];
if (api) {
[channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
FlutterError *error;
FLTMixWithOthersMessage *input = [FLTMixWithOthersMessage fromMap:message];
[api setMixWithOthers:input error:&error];
callback(wrapResult(nil, error));
}];
} else {
[channel setMessageHandler:nil];
}
}
}
18 changes: 4 additions & 14 deletions packages/video_player/video_player/lib/video_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import 'package:meta/meta.dart';

import 'package:video_player_platform_interface/video_player_platform_interface.dart';
export 'package:video_player_platform_interface/video_player_platform_interface.dart'
show DurationRange, DataSourceType, VideoFormat, VideoPlayerOptions;
show DurationRange, DataSourceType, VideoFormat;

import 'src/closed_caption_file.dart';
export 'src/closed_caption_file.dart';
Expand Down Expand Up @@ -168,7 +168,7 @@ class VideoPlayerController extends ValueNotifier<VideoPlayerValue> {
/// null. The [package] argument must be non-null when the asset comes from a
/// package and null otherwise.
VideoPlayerController.asset(this.dataSource,
{this.package, this.closedCaptionFile, this.videoPlayerOptions})
{this.package, this.closedCaptionFile})
: dataSourceType = DataSourceType.asset,
formatHint = null,
super(VideoPlayerValue(duration: null));
Expand All @@ -181,7 +181,7 @@ class VideoPlayerController extends ValueNotifier<VideoPlayerValue> {
/// **Android only**: The [formatHint] option allows the caller to override
/// the video format detection code.
VideoPlayerController.network(this.dataSource,
{this.formatHint, this.closedCaptionFile, this.videoPlayerOptions})
{this.formatHint, this.closedCaptionFile})
: dataSourceType = DataSourceType.network,
package = null,
super(VideoPlayerValue(duration: null));
Expand All @@ -190,8 +190,7 @@ class VideoPlayerController extends ValueNotifier<VideoPlayerValue> {
///
/// This will load the file from the file-URI given by:
/// `'file://${file.path}'`.
VideoPlayerController.file(File file,
{this.closedCaptionFile, this.videoPlayerOptions})
VideoPlayerController.file(File file, {this.closedCaptionFile})
: dataSource = 'file://${file.path}',
dataSourceType = DataSourceType.file,
package = null,
Expand All @@ -212,9 +211,6 @@ class VideoPlayerController extends ValueNotifier<VideoPlayerValue> {
/// is constructed with.
final DataSourceType dataSourceType;

/// Provide additional configuration options (optional). Like setting the audio mode to mix
final VideoPlayerOptions videoPlayerOptions;

/// Only set for [asset] videos. The package that the asset was loaded from.
final String package;

Expand Down Expand Up @@ -266,12 +262,6 @@ class VideoPlayerController extends ValueNotifier<VideoPlayerValue> {
);
break;
}

if (videoPlayerOptions?.mixWithOthers != null) {
await _videoPlayerPlatform
.setMixWithOthers(videoPlayerOptions.mixWithOthers);
}

_textureId = await _videoPlayerPlatform.create(dataSourceDescription);
_creatingCompleter.complete(null);
final Completer<void> initializingCompleter = Completer<void>();
Expand Down
5 changes: 0 additions & 5 deletions packages/video_player/video_player/pigeons/messages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ class CreateMessage {
String formatHint;
}

class MixWithOthersMessage {
bool mixWithOthers;
}

@HostApi()
abstract class VideoPlayerApi {
void initialize();
Expand All @@ -41,7 +37,6 @@ abstract class VideoPlayerApi {
PositionMessage position(TextureMessage msg);
void seekTo(PositionMessage msg);
void pause(TextureMessage msg);
void setMixWithOthers(MixWithOthersMessage msg);
}

void configurePigeon(PigeonOptions opts) {
Expand Down
2 changes: 1 addition & 1 deletion packages/video_player/video_player/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: Flutter plugin for displaying inline video with other Flutter
# 0.10.y+z is compatible with 1.0.0, if you land a breaking change bump
# the version to 2.0.0.
# See more details: https://github.com/flutter/flutter/wiki/Package-migration-to-1.0.0
version: 0.10.12
version: 0.10.11+2
homepage: https://github.com/flutter/plugins/tree/master/packages/video_player/video_player

flutter:
Expand Down
Loading

0 comments on commit d4750ea

Please sign in to comment.