Skip to content

Commit 9f80c5b

Browse files
authored
Run formatter on all package code (google#41)
1 parent 4e9a3e3 commit 9f80c5b

File tree

9 files changed

+474
-446
lines changed

9 files changed

+474
-446
lines changed

packages/audiofileplayer/android/src/main/java/com/google/flutter/plugins/audiofileplayer/AudiofileplayerPlugin.java

+126-118
Large diffs are not rendered by default.

packages/audiofileplayer/android/src/main/java/com/google/flutter/plugins/audiofileplayer/AudiofileplayerService.java

+291-283
Large diffs are not rendered by default.

packages/audiofileplayer/android/src/main/java/com/google/flutter/plugins/audiofileplayer/LocalManagedMediaPlayer.java

+8-7
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import android.content.res.AssetFileDescriptor;
55
import android.media.MediaPlayer;
66
import android.os.Build;
7-
87
import java.io.File;
98
import java.io.FileInputStream;
109
import java.io.FileOutputStream;
@@ -25,7 +24,9 @@ class LocalManagedMediaPlayer extends ManagedMediaPlayer {
2524
* <p>Callers must subsequently set a data source and call {@link MediaPlayer#prepare()}.
2625
*/
2726
private LocalManagedMediaPlayer(
28-
String audioId, AudiofileplayerPlugin parentAudioPlugin, boolean looping,
27+
String audioId,
28+
AudiofileplayerPlugin parentAudioPlugin,
29+
boolean looping,
2930
boolean playInBackground)
3031
throws IllegalArgumentException, IOException {
3132
super(audioId, parentAudioPlugin, looping, playInBackground);
@@ -54,12 +55,12 @@ public LocalManagedMediaPlayer(
5455
/**
5556
* Create a ManagedMediaPlayer from a byte array.
5657
*
57-
* Uses {@link android.media.MediaPlayer#setDataSource(android.media.MediaDataSource)} if available.
58-
* Otherwise falls back to writing the byte[] to disk and reading it back.
58+
* <p>Uses {@link android.media.MediaPlayer#setDataSource(android.media.MediaDataSource)} if
59+
* available. Otherwise falls back to writing the byte[] to disk and reading it back.
5960
*
6061
* @throws IllegalArgumentException if BufferMediaDataSource is invalid.
61-
* @throws IOException if underlying MediaPlayer cannot load BufferMediaDataSource
62-
* or FileDescriptor.
62+
* @throws IOException if underlying MediaPlayer cannot load BufferMediaDataSource or
63+
* FileDescriptor.
6364
*/
6465
public LocalManagedMediaPlayer(
6566
String audioId,
@@ -75,7 +76,7 @@ public LocalManagedMediaPlayer(
7576
} else {
7677
// On older SDK versions, write the byte[] to disk, then read as FileDescriptor.
7778
File tempAudioFile =
78-
File.createTempFile(UUID.randomUUID().toString(), null, context.getCacheDir());
79+
File.createTempFile(UUID.randomUUID().toString(), null, context.getCacheDir());
7980
tempAudioFile.deleteOnExit();
8081
FileOutputStream fos = new FileOutputStream(tempAudioFile);
8182
fos.write(audioBytes);

packages/audiofileplayer/android/src/main/java/com/google/flutter/plugins/audiofileplayer/ManagedMediaPlayer.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,11 @@ public void run() {
4343
}
4444
};
4545

46-
protected ManagedMediaPlayer(String audioId, AudiofileplayerPlugin parentAudioPlugin,
47-
boolean looping, boolean playInBackground) {
46+
protected ManagedMediaPlayer(
47+
String audioId,
48+
AudiofileplayerPlugin parentAudioPlugin,
49+
boolean looping,
50+
boolean playInBackground) {
4851
this.parentAudioPlugin = parentAudioPlugin;
4952
this.audioId = audioId;
5053
this.playInBackground = playInBackground;

packages/audiofileplayer/android/src/main/java/com/google/flutter/plugins/audiofileplayer/RemoteManagedMediaPlayer.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ interface OnRemoteLoadListener {
4646
* @throws IOException if underlying MediaPlayer cannot load it as its DataSource.
4747
*/
4848
public RemoteManagedMediaPlayer(
49-
String audioId, String remoteUrl, AudiofileplayerPlugin parentAudioPlugin, boolean looping,
49+
String audioId,
50+
String remoteUrl,
51+
AudiofileplayerPlugin parentAudioPlugin,
52+
boolean looping,
5053
boolean playInBackground)
5154
throws IOException {
5255
super(audioId, parentAudioPlugin, looping, playInBackground);

packages/audiofileplayer/ios/Classes/AudiofileplayerPlugin.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
* Receives messages which create, trigger, and destroy instances of
77
* FLTManagedPlayer.
88
*/
9-
@interface AudiofileplayerPlugin : NSObject <FlutterPlugin>
9+
@interface AudiofileplayerPlugin : NSObject<FlutterPlugin>
1010
@end

packages/audiofileplayer/ios/Classes/AudiofileplayerPlugin.m

+32-28
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
#import "AudiofileplayerPlugin.h"
12
#import <AVFoundation/AVFoundation.h>
23
#import <MediaPlayer/MediaPlayer.h>
3-
#import "AudiofileplayerPlugin.h"
44
#import "ManagedPlayer.h"
55

66
static NSString *const kChannel = @"audiofileplayer";
@@ -66,7 +66,7 @@
6666
static NSString *const kMediaSkipBackward = @"skipBackward";
6767
static NSString *const kMediaSkipIntervalSeconds = @"skipIntervalSeconds";
6868

69-
@interface AudiofileplayerPlugin () <FLTManagedPlayerDelegate>
69+
@interface AudiofileplayerPlugin ()<FLTManagedPlayerDelegate>
7070
@end
7171

7272
@implementation AudiofileplayerPlugin {
@@ -79,8 +79,8 @@ @implementation AudiofileplayerPlugin {
7979
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar {
8080
FlutterMethodChannel *channel =
8181
[FlutterMethodChannel methodChannelWithName:kChannel binaryMessenger:[registrar messenger]];
82-
AudiofileplayerPlugin *instance = [[AudiofileplayerPlugin alloc] initWithRegistrar:registrar
83-
channel:channel];
82+
AudiofileplayerPlugin *instance =
83+
[[AudiofileplayerPlugin alloc] initWithRegistrar:registrar channel:channel];
8484
[registrar addMethodCallDelegate:instance channel:channel];
8585
[registrar addApplicationDelegate:instance];
8686
}
@@ -96,8 +96,7 @@ - (instancetype)initWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar
9696
[self addCommandHandlers];
9797
[self disableCommandHandlers];
9898
// Set audio category to initial default of 'playback'.
99-
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback
100-
error:nil];
99+
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
101100
}
102101
return self;
103102
}
@@ -110,7 +109,7 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result
110109
NSLog(@"handleMethodCall: method = %@", call.method);
111110

112111
if ([call.method isEqualToString:kLoadMethod]) {
113-
// Loading an audio instance.
112+
// Loading an audio instance.
114113
[self handleLoadWithCall:call result:result];
115114
return;
116115
} else if ([call.method isEqualToString:kAudioCategoryMethod]) {
@@ -121,7 +120,8 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result
121120
category = AVAudioSessionCategorySoloAmbient;
122121
} else if ([categoryString isEqualToString:kAudioCategoryAmbientMixed]) {
123122
category = AVAudioSessionCategoryAmbient;
124-
} if ([categoryString isEqualToString:kAudioCategoryPlayback]) {
123+
}
124+
if ([categoryString isEqualToString:kAudioCategoryPlayback]) {
125125
category = AVAudioSessionCategoryPlayback;
126126
}
127127
[[AVAudioSession sharedInstance] setCategory:category error:nil];
@@ -320,8 +320,9 @@ - (void)addCommandHandlers {
320320
action:@selector(handleSeekForwardCommand:)];
321321
[remoteCommandCenter.seekBackwardCommand addTarget:self
322322
action:@selector(handleSeekBackwardCommand:)];
323-
[remoteCommandCenter.changePlaybackPositionCommand addTarget:self
324-
action:@selector(handleChangePlaybackPositionCommand:)];
323+
[remoteCommandCenter.changePlaybackPositionCommand
324+
addTarget:self
325+
action:@selector(handleChangePlaybackPositionCommand:)];
325326
[remoteCommandCenter.skipForwardCommand addTarget:self
326327
action:@selector(handleSkipForwardCommand:)];
327328
[remoteCommandCenter.skipBackwardCommand addTarget:self
@@ -332,9 +333,9 @@ - (void)disableCommandHandlers {
332333
MPRemoteCommandCenter *remoteCommandCenter = [MPRemoteCommandCenter sharedCommandCenter];
333334
remoteCommandCenter.togglePlayPauseCommand.enabled = NO;
334335
remoteCommandCenter.playCommand.enabled = NO;
335-
remoteCommandCenter.pauseCommand.enabled = NO;
336+
remoteCommandCenter.pauseCommand.enabled = NO;
336337
remoteCommandCenter.nextTrackCommand.enabled = NO;
337-
remoteCommandCenter.previousTrackCommand.enabled = NO;
338+
remoteCommandCenter.previousTrackCommand.enabled = NO;
338339
remoteCommandCenter.seekForwardCommand.enabled = NO;
339340
remoteCommandCenter.seekBackwardCommand.enabled = NO;
340341
remoteCommandCenter.changePlaybackPositionCommand.enabled = NO;
@@ -378,11 +379,11 @@ - (void)enableCommandHandlersFromMediaActionTypes:(NSArray<NSString *> *)mediaAc
378379
remoteCommandCenter.skipBackwardCommand.enabled =
379380
[mediaActionTypes containsObject:kMediaSkipBackward];
380381
if (skipIntervalNumber) {
381-
remoteCommandCenter.skipForwardCommand.preferredIntervals = @[skipIntervalNumber];
382-
remoteCommandCenter.skipBackwardCommand.preferredIntervals =@[skipIntervalNumber];
382+
remoteCommandCenter.skipForwardCommand.preferredIntervals = @[ skipIntervalNumber ];
383+
remoteCommandCenter.skipBackwardCommand.preferredIntervals = @[ skipIntervalNumber ];
383384
}
384385
}
385-
386+
386387
- (MPRemoteCommandHandlerStatus)handleTogglePlayPauseCommand:
387388
(MPRemoteCommandEvent *)remoteCommandEvent {
388389
[_channel invokeMethod:kOnMediaEventCallback arguments:@{kMediaEventType : kMediaPlayPause}];
@@ -426,17 +427,20 @@ - (MPRemoteCommandHandlerStatus)handleChangePlaybackPositionCommand:
426427
(MPChangePlaybackPositionCommandEvent *)changePlaybackPositionCommandEvent {
427428
NSTimeInterval positionSeconds = changePlaybackPositionCommandEvent.positionTime;
428429
[_channel invokeMethod:kOnMediaEventCallback
429-
arguments:@{kMediaEventType : kMediaSeekTo,
430-
kMediaSeekToPositionSeconds:@(positionSeconds)
431-
}];
430+
arguments:@{
431+
kMediaEventType : kMediaSeekTo,
432+
kMediaSeekToPositionSeconds : @(positionSeconds)
433+
}];
432434
return MPRemoteCommandHandlerStatusSuccess;
433435
}
434436

435437
- (MPRemoteCommandHandlerStatus)handleSkipForwardCommand:
436438
(MPSkipIntervalCommandEvent *)skipIntervalCommandEvent {
437439
[_channel invokeMethod:kOnMediaEventCallback
438-
arguments:@{kMediaEventType : kMediaSkipForward,
439-
kMediaSkipIntervalSeconds:@(skipIntervalCommandEvent.interval)}];
440+
arguments:@{
441+
kMediaEventType : kMediaSkipForward,
442+
kMediaSkipIntervalSeconds : @(skipIntervalCommandEvent.interval)
443+
}];
440444
return MPRemoteCommandHandlerStatusSuccess;
441445
}
442446

@@ -448,36 +452,36 @@ - (MPRemoteCommandHandlerStatus)handleSkipBackwardCommand:
448452

449453
#pragma mark - MPNowPlayingInfoCenter
450454

451-
- (void) updateNowPlayingInfoFromPlaybackState:(NSDictionary *) playbackState {
455+
- (void)updateNowPlayingInfoFromPlaybackState:(NSDictionary *)playbackState {
452456
bool isPlaying = [playbackState[kPlaybackIsPlaying] boolValue];
453457
_nowPlayingInfo[MPNowPlayingInfoPropertyPlaybackRate] = isPlaying ? @(1.0) : @(0.0);
454458
_nowPlayingInfo[MPNowPlayingInfoPropertyElapsedPlaybackTime] =
455459
playbackState[kPlaybackPositionSeconds];
456-
460+
457461
MPNowPlayingInfoCenter.defaultCenter.nowPlayingInfo = _nowPlayingInfo;
458462
}
459463

460-
- (void) updateNowPlayingInfoFromMetadata:(NSDictionary *) metadata {
464+
- (void)updateNowPlayingInfoFromMetadata:(NSDictionary *)metadata {
461465
_nowPlayingInfo[MPMediaItemPropertyPersistentID] = metadata[kMetadataId];
462466
_nowPlayingInfo[MPMediaItemPropertyTitle] = metadata[kMetadataTitle];
463467
_nowPlayingInfo[MPMediaItemPropertyArtist] = metadata[kMetadataArtist];
464468
_nowPlayingInfo[MPMediaItemPropertyAlbumTitle] = metadata[kMetadataAlbum];
465469
_nowPlayingInfo[MPMediaItemPropertyGenre] = metadata[kMetadataGenre];
466470
_nowPlayingInfo[MPMediaItemPropertyPlaybackDuration] = metadata[kMetadataDurationSeconds];
467-
471+
468472
if (metadata[kMetadataArtBytes]) {
469473
FlutterStandardTypedData *flutterData = metadata[kMetadataArtBytes];
470474
NSData *data = [flutterData data];
471475
UIImage *image = [UIImage imageWithData:data];
472476
_nowPlayingInfo[MPMediaItemPropertyArtwork] =
473477
[[MPMediaItemArtwork alloc] initWithBoundsSize:CGSizeMake(200.0, 200.0)
474-
requestHandler:^UIImage *(CGSize size) {
475-
return image;
476-
}];
478+
requestHandler:^UIImage *(CGSize size) {
479+
return image;
480+
}];
477481
} else {
478482
_nowPlayingInfo[MPMediaItemPropertyArtwork] = nil;
479483
}
480-
484+
481485
MPNowPlayingInfoCenter.defaultCenter.nowPlayingInfo = _nowPlayingInfo;
482486
}
483487

packages/audiofileplayer/ios/Classes/ManagedPlayer.m

+5-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
static NSString *const kKeyPathStatus = @"status";
88
static float const kTimerUpdateIntervalSeconds = 0.25;
99

10-
@interface FLTManagedPlayer () <AVAudioPlayerDelegate>
10+
@interface FLTManagedPlayer ()<AVAudioPlayerDelegate>
1111
@end
1212

1313
@implementation FLTManagedPlayer {
@@ -260,9 +260,10 @@ - (void)observeValueForKeyPath:(NSString *)keyPath
260260
}
261261
case AVPlayerItemStatusFailed: {
262262
if (item.error.code == -11800) {
263-
NSLog(@"It looks like you are failing to load a remote asset. You probably requested a "
264-
@"non-https url, and didn't specify arbitrary url loading in your app transport "
265-
@"securty settings. Add an NSAppTransportSecurity entry to your Info.plist.");
263+
NSLog(
264+
@"It looks like you are failing to load a remote asset. You probably requested a "
265+
@"non-https url, and didn't specify arbitrary url loading in your app transport "
266+
@"securty settings. Add an NSAppTransportSecurity entry to your Info.plist.");
266267
}
267268
_remoteLoadHandler(NO);
268269
break;

packages/audiofileplayer/lib/audiofileplayer.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ const String mediaCustomTitleKey = 'customTitle';
5656
const String mediaCustomEventIdKey = 'customEventId';
5757
const String mediaCustomDrawableResourceKey = 'customDrawableResource';
5858

59-
MethodChannel audioMethodChannel =
60-
const MethodChannel(channelName)..setMethodCallHandler(Audio.handleMethodCall);
59+
MethodChannel audioMethodChannel = const MethodChannel(channelName)
60+
..setMethodCallHandler(Audio.handleMethodCall);
6161

6262
/// Specifies an action that the OS's background audio system may support.
6363
///

0 commit comments

Comments
 (0)