Skip to content

Commit

Permalink
Merge branch 'feature/swiftpm' into minor
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanheise committed Jan 28, 2025
2 parents d223331 + 0bd8a52 commit e9f1e6e
Show file tree
Hide file tree
Showing 72 changed files with 205 additions and 343 deletions.
2 changes: 2 additions & 0 deletions just_audio/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
**/ios/Flutter/flutter_assets/
**/ios/ServiceDefinitions.json
**/ios/Runner/GeneratedPluginRegistrant.*
.build/
.swiftpm/

# Exceptions to above rules.
!**/ios/**/default.mode1v3
Expand Down
4 changes: 4 additions & 0 deletions just_audio/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.9.44

* Add support for SwiftPM.

## 0.9.43

* Fix NPE in load on iOS/macOS.
Expand Down
36 changes: 27 additions & 9 deletions just_audio/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,14 +281,28 @@ dependencies {

### iOS

If you wish to connect to non-HTTPS URLs, or if you use a feature that depends on the proxy such as headers, caching or stream audio sources, add the following to your `Info.plist` file:

```xml
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
```

Using the default configuration, the App Store will detect that your app uses the AVAudioSession API which includes a microphone API, and for privacy reasons it will ask you to describe your app's usage of the microphone. If your app does indeed use the microphone, you can describe your usage by editing the `Info.plist` file as follows:

```xml
<key>NSMicrophoneUsageDescription</key>
<string>... explain why the app uses the microphone here ...</string>
```

But if your app does not use the microphone, you can pass a build option to "compile out" any microphone code so that the App Store won't ask for the above usage description. To do so, edit your `ios/Podfile` as follows:
But if your app doesn't use the microphone, you can pass a build option to "compile out" any microphone code so that the App Store won't ask for the above usage description. This can be done with either CocoaPods or SwiftPM builds.

#### CocoaPods

Edit your `ios/Podfile` as follows:

```ruby
post_install do |installer|
Expand All @@ -307,17 +321,21 @@ post_install do |installer|
end
```

If you wish to connect to non-HTTPS URLs, or if you use a feature that depends on the proxy such as headers, caching or stream audio sources, add the following to your `Info.plist` file:
#### SwiftPM

```xml
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
Run `flutter clean` to force SwiftPM to pick up your new settings:

```
flutter clean
```

Export the environment variable `AUDIO_SESSION_MICROPHONE=0` before running your build command. E.g. Using the bash command line:

```
AUDIO_SESSION_MICROPHONE=0 flutter run
```

The iOS player relies on server headers (e.g. `Content-Type`, `Content-Length` and [byte range requests](https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariWebContent/CreatingVideoforSafarioniPhone/CreatingVideoforSafarioniPhone.html#//apple_ref/doc/uid/TP40006514-SW6)) to know how to decode the file and where applicable to report its duration. In the case of files, iOS relies on the file extension.
Note: `flutter clean` is needed whenever the value of `AUDIO_SESSION_MICROPHONE` changes, or whenever you switch between different projects that use audio_session with different `AUDIO_SESSION_MICROPHONE` values.

### macOS

Expand Down
6 changes: 0 additions & 6 deletions just_audio/darwin/Classes/IndexedPlayerItem.m

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@
Pod::Spec.new do |s|
s.name = 'just_audio'
s.version = '0.0.1'
s.summary = 'A new flutter plugin project.'
s.summary = 'Flutter audio player'
s.description = <<-DESC
A new flutter plugin project.
A flutter plugin for playing audio.
DESC
s.homepage = 'http://example.com'
s.homepage = 'https://github.com/ryanheise/just_audio'
s.license = { :file => '../LICENSE' }
s.author = { 'Your Company' => '[email protected]' }
s.source = { :path => '.' }
s.source_files = 'Classes/**/*'
s.public_header_files = 'Classes/**/*.h'
s.dependency 'FlutterMacOS'
s.platform = :osx, '10.12.2'
s.source_files = 'just_audio/Sources/just_audio/**/*.{h,m}'
s.public_header_files = 'just_audio/Sources/just_audio/include/**/*.h'
s.ios.dependency 'Flutter'
s.osx.dependency 'FlutterMacOS'
s.ios.deployment_target = '12.0'
s.osx.deployment_target = '10.14'
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' }
end

25 changes: 25 additions & 0 deletions just_audio/darwin/just_audio/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// swift-tools-version: 5.9
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "just_audio",
platforms: [
.iOS("12.0"),
.macOS("10.14")
],
products: [
.library(name: "just-audio", targets: ["just_audio"])
],
dependencies: [],
targets: [
.target(
name: "just_audio",
dependencies: [],
cSettings: [
.headerSearchPath("include/just_audio")
]
)
]
)
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#import "BetterEventChannel.h"
#import "AudioPlayer.h"
#import "AudioSource.h"
#import "IndexedAudioSource.h"
#import "LoadControl.h"
#import "UriAudioSource.h"
#import "ConcatenatingAudioSource.h"
#import "LoopingAudioSource.h"
#import "ClippingAudioSource.h"
#import "./include/just_audio/BetterEventChannel.h"
#import "./include/just_audio/AudioPlayer.h"
#import "./include/just_audio/AudioSource.h"
#import "./include/just_audio/IndexedAudioSource.h"
#import "./include/just_audio/LoadControl.h"
#import "./include/just_audio/UriAudioSource.h"
#import "./include/just_audio/ConcatenatingAudioSource.h"
#import "./include/just_audio/LoopingAudioSource.h"
#import "./include/just_audio/ClippingAudioSource.h"
#import <AVFoundation/AVFoundation.h>
#import <stdlib.h>
#include <TargetConditionals.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import "AudioSource.h"
#import "./include/just_audio/AudioSource.h"
#import <AVFoundation/AVFoundation.h>

@implementation AudioSource {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import "BetterEventChannel.h"
#import "./include/just_audio/BetterEventChannel.h"

@implementation BetterEventChannel {
FlutterEventChannel *_eventChannel;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#import "AudioSource.h"
#import "ClippingAudioSource.h"
#import "IndexedPlayerItem.h"
#import "UriAudioSource.h"
#import "./include/just_audio/AudioSource.h"
#import "./include/just_audio/ClippingAudioSource.h"
#import "./include/just_audio/IndexedPlayerItem.h"
#import "./include/just_audio/UriAudioSource.h"
#import <AVFoundation/AVFoundation.h>

@implementation ClippingAudioSource {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#import "AudioSource.h"
#import "ConcatenatingAudioSource.h"
#import "./include/just_audio/AudioSource.h"
#import "./include/just_audio/ConcatenatingAudioSource.h"
#import <AVFoundation/AVFoundation.h>
#import <stdlib.h>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#import "IndexedAudioSource.h"
#import "IndexedPlayerItem.h"
#import "./include/just_audio/IndexedAudioSource.h"
#import "./include/just_audio/IndexedPlayerItem.h"
#import <AVFoundation/AVFoundation.h>

@implementation IndexedAudioSource {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#import "./include/just_audio/IndexedPlayerItem.h"
#import "./include/just_audio/IndexedAudioSource.h"

@implementation IndexedPlayerItem
@synthesize audioSource;
@end
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#import "JustAudioPlugin.h"
#import "AudioPlayer.h"
#import "./include/just_audio/JustAudioPlugin.h"
#import "./include/just_audio/AudioPlayer.h"
#import <AVFoundation/AVFoundation.h>
#include <TargetConditionals.h>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import "LoadControl.h"
#import "./include/just_audio/LoadControl.h"

@implementation LoadControl
@synthesize preferredForwardBufferDuration;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#import "AudioSource.h"
#import "LoopingAudioSource.h"
#import "./include/just_audio/AudioSource.h"
#import "./include/just_audio/LoopingAudioSource.h"
#import <AVFoundation/AVFoundation.h>

@implementation LoopingAudioSource {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#import "UriAudioSource.h"
#import "IndexedAudioSource.h"
#import "IndexedPlayerItem.h"
#import "LoadControl.h"
#import "./include/just_audio/UriAudioSource.h"
#import "./include/just_audio/IndexedAudioSource.h"
#import "./include/just_audio/IndexedPlayerItem.h"
#import "./include/just_audio/LoadControl.h"
#import <AVFoundation/AVFoundation.h>

@implementation UriAudioSource {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#if TARGET_OS_OSX
#import <FlutterMacOS/FlutterMacOS.h>
#else
#import <Flutter/Flutter.h>
#endif
#import <AVFoundation/AVFoundation.h>

@interface AudioPlayer : NSObject<AVPlayerItemMetadataOutputPushDelegate>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#if TARGET_OS_OSX
#import <FlutterMacOS/FlutterMacOS.h>
#else
#import <Flutter/Flutter.h>
#endif

@interface AudioSource : NSObject

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#if TARGET_OS_OSX
#import <FlutterMacOS/FlutterMacOS.h>
#else
#import <Flutter/Flutter.h>
#endif

@interface BetterEventChannel : NSObject<FlutterStreamHandler>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#import "AudioSource.h"
#import "UriAudioSource.h"
#if TARGET_OS_OSX
#import <FlutterMacOS/FlutterMacOS.h>
#else
#import <Flutter/Flutter.h>
#endif

@interface ClippingAudioSource : IndexedAudioSource

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#import "AudioSource.h"
#if TARGET_OS_OSX
#import <FlutterMacOS/FlutterMacOS.h>
#else
#import <Flutter/Flutter.h>
#endif

@interface ConcatenatingAudioSource : AudioSource

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#import "AudioSource.h"
#import "IndexedPlayerItem.h"
#if TARGET_OS_OSX
#import <FlutterMacOS/FlutterMacOS.h>
#else
#import <Flutter/Flutter.h>
#endif
#import <AVFoundation/AVFoundation.h>

@interface IndexedAudioSource : AudioSource
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#if TARGET_OS_OSX
#import <FlutterMacOS/FlutterMacOS.h>
#else
#import <Flutter/Flutter.h>
#endif

@interface JustAudioPlugin : NSObject<FlutterPlugin>
@end
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#import <Foundation/Foundation.h>

@interface LoadControl : NSObject

@property (readwrite, nonatomic) NSNumber *preferredForwardBufferDuration;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#import "AudioSource.h"
#if TARGET_OS_OSX
#import <FlutterMacOS/FlutterMacOS.h>
#else
#import <Flutter/Flutter.h>
#endif

@interface LoopingAudioSource : AudioSource

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#import "IndexedAudioSource.h"
#import "LoadControl.h"
#if TARGET_OS_OSX
#import <FlutterMacOS/FlutterMacOS.h>
#else
#import <Flutter/Flutter.h>
#endif

@interface UriAudioSource : IndexedAudioSource

Expand Down
8 changes: 8 additions & 0 deletions just_audio/example/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,19 @@ require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelpe
flutter_ios_podfile_setup

target 'Runner' do
use_frameworks!
use_modular_headers!
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
target.build_configurations.each do |config|
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
'$(inherited)',
'AUDIO_SESSION_MICROPHONE=0'
]
end
end
end
Loading

0 comments on commit e9f1e6e

Please sign in to comment.