Disable setCategory on macOS

This commit is contained in:
Ryan Heise 2020-08-07 04:08:02 +10:00
parent e89417119c
commit 122a90b4fb
6 changed files with 50 additions and 31 deletions

View File

@ -12,19 +12,19 @@ A Flutter plugin to play audio from URLs, files, assets, DASH/HLS streams and pl
| request headers | ✅ | ✅ | ✅ | |
| DASH | ✅ | (untested) | (untested) | (untested) |
| HLS | ✅ | ✅ | (untested) | (untested) |
| buffer status/position | ✅ | ✅ | (untested) | ✅ |
| buffer status/position | ✅ | ✅ | | ✅ |
| play/pause/seek | ✅ | ✅ | ✅ | ✅ |
| set volume | ✅ | ✅ | (untested) | ✅ |
| set volume | ✅ | ✅ | | ✅ |
| set speed | ✅ | ✅ | ✅ | ✅ |
| clip audio | ✅ | ✅ | (untested) | ✅ |
| playlists | ✅ | ✅ | (untested) | ✅ |
| looping | ✅ | ✅ | (untested) | ✅ |
| shuffle | ✅ | ✅ | (untested) | ✅ |
| compose audio | ✅ | ✅ | (untested) | ✅ |
| gapless playback | ✅ | ✅ | (untested) | |
| clip audio | ✅ | ✅ | | ✅ |
| playlists | ✅ | ✅ | | ✅ |
| looping | ✅ | ✅ | | ✅ |
| shuffle | ✅ | ✅ | | ✅ |
| compose audio | ✅ | ✅ | | ✅ |
| gapless playback | ✅ | ✅ | | |
| report player errors | ✅ | ✅ | ✅ | ✅ |
This plugin has been tested on Android, iOS and Web, and is being made available for testing on MacOS. Please consider reporting any bugs you encounter [here](https://github.com/ryanheise/just_audio/issues) or submitting pull requests [here](https://github.com/ryanheise/just_audio/pulls).
Please consider reporting any bugs you encounter [here](https://github.com/ryanheise/just_audio/issues) or submitting pull requests [here](https://github.com/ryanheise/just_audio/pulls).
## Example

View File

@ -7,6 +7,7 @@
#import "ClippingAudioSource.h"
#import <AVFoundation/AVFoundation.h>
#import <stdlib.h>
#include <TargetConditionals.h>
// TODO: Check for and report invalid state transitions.
// TODO: Apply Apple's guidance on seeking: https://developer.apple.com/library/archive/qa/qa1820/_index.html
@ -865,9 +866,11 @@
_playResult = result;
}
_playing = YES;
#if TARGET_OS_IPHONE
if (_configuredSession) {
[[AVAudioSession sharedInstance] setActive:YES error:nil];
}
#endif
[_player play];
[self updatePosition];
if (@available(macOS 10.12, iOS 10.0, *)) {}

View File

@ -1,6 +1,7 @@
#import "JustAudioPlugin.h"
#import "AudioPlayer.h"
#import <AVFoundation/AVFoundation.h>
#include <TargetConditionals.h>
@implementation JustAudioPlugin {
NSObject<FlutterPluginRegistrar>* _registrar;
@ -29,6 +30,7 @@
/*AudioPlayer* player =*/ [[AudioPlayer alloc] initWithRegistrar:_registrar playerId:playerId configuredSession:_configuredSession];
result(nil);
} else if ([@"setIosCategory" isEqualToString:call.method]) {
#if TARGET_OS_IPHONE
NSNumber* categoryIndex = (NSNumber*)call.arguments;
AVAudioSessionCategory category = nil;
switch (categoryIndex.integerValue) {
@ -43,6 +45,7 @@
_configuredSession = YES;
}
[[AVAudioSession sharedInstance] setCategory:category error:nil];
#endif
result(nil);
} else {
result(FlutterMethodNotImplemented);

View File

@ -5,8 +5,10 @@
import FlutterMacOS
import Foundation
import path_provider_macos
import just_audio
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
JustAudioPlugin.register(with: registry.registrar(forPlugin: "JustAudioPlugin"))
}

View File

@ -2,21 +2,32 @@ PODS:
- FlutterMacOS (1.0.0)
- just_audio (0.0.1):
- FlutterMacOS
- path_provider (0.0.1)
- path_provider_macos (0.0.1):
- FlutterMacOS
DEPENDENCIES:
- FlutterMacOS (from `Flutter/ephemeral/.symlinks/flutter/darwin-x64`)
- just_audio (from `Flutter/ephemeral/.symlinks/plugins/just_audio/macos`)
- path_provider (from `Flutter/ephemeral/.symlinks/plugins/path_provider/macos`)
- path_provider_macos (from `Flutter/ephemeral/.symlinks/plugins/path_provider_macos/macos`)
EXTERNAL SOURCES:
FlutterMacOS:
:path: Flutter/ephemeral/.symlinks/flutter/darwin-x64
just_audio:
:path: Flutter/ephemeral/.symlinks/plugins/just_audio/macos
path_provider:
:path: Flutter/ephemeral/.symlinks/plugins/path_provider/macos
path_provider_macos:
:path: Flutter/ephemeral/.symlinks/plugins/path_provider_macos/macos
SPEC CHECKSUMS:
FlutterMacOS: 15bea8a44d2fa024068daa0140371c020b4b6ff9
just_audio: 1a11463e7e522bd4e8caa925b4247f1360cbe5a2
path_provider: e0848572d1d38b9a7dd099e79cf83f5b7e2cde9f
path_provider_macos: a0a3fd666cb7cd0448e936fb4abad4052961002b
PODFILE CHECKSUM: d8ba9b3e9e93c62c74a660b46c6fcb09f03991a7
COCOAPODS: 1.7.5
COCOAPODS: 1.9.3

View File

@ -21,7 +21,7 @@ packages:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
version: "1.1.0-nullsafety"
charcode:
dependency: transitive
description:
@ -42,7 +42,7 @@ packages:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.14.13"
version: "1.15.0-nullsafety"
convert:
dependency: transitive
description:
@ -120,7 +120,7 @@ packages:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.8"
version: "1.3.0-nullsafety"
path:
dependency: transitive
description:
@ -237,7 +237,7 @@ packages:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.3.0-nullsafety"
uuid:
dependency: transitive
description:
@ -251,7 +251,7 @@ packages:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.8"
version: "2.1.0-nullsafety"
xdg_directories:
dependency: transitive
description:
@ -260,5 +260,5 @@ packages:
source: hosted
version: "0.1.0"
sdks:
dart: ">=2.9.0-14.0.dev <3.0.0"
dart: ">=2.9.0-18.0 <2.9.0"
flutter: ">=1.12.13+hotfix.5 <2.0.0"