Skip to content

Commit

Permalink
Merge branch 'feature/bump_web' into minor
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanheise committed May 18, 2024
2 parents b5595f5 + 6e36ce4 commit 173c0d1
Show file tree
Hide file tree
Showing 22 changed files with 127 additions and 81 deletions.
5 changes: 5 additions & 0 deletions just_audio/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.9.38

* Migrate to package:web.
* Add AudioPlayer.setWebCrossOrigin for CORS on web (@danielwinkler).

## 0.9.37

* Support useLazyPreparation on iOS/macOS.
Expand Down
5 changes: 4 additions & 1 deletion just_audio/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ Please also consider pressing the thumbs up button at the top of [this page](htt
| read from file | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| read from asset | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| read from byte stream | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| request headers | ✅ | ✅ | ✅ | | ✅ | ✅ |
| request headers | ✅ | ✅ | ✅ | * | ✅ | ✅ |
| DASH | ✅ | | | | ✅ | ✅ |
| HLS | ✅ | ✅ | ✅ | | ✅ | ✅ |
| ICY metadata | ✅ | ✅ | ✅ | | | |
Expand All @@ -456,6 +456,9 @@ Please also consider pressing the thumbs up button at the top of [this page](htt
| equalizer | ✅ | | | | | ✅ |
| volume boost | ✅ | | | | | ✅ |

(*): While request headers cannot be set directly on Web, cookies can be used to send information in the [Cookie header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cookie). See also `AudioPlayer.setWebCrossOrigin` to allow sending cookies when loading audio files from the same origin or a different origin.


## Experimental features

| Feature | Android | iOS | macOS | Web |
Expand Down
19 changes: 10 additions & 9 deletions just_audio/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ android {
if (project.android.hasProperty("namespace")) {
namespace 'com.ryanheise.just_audio'
}
compileSdkVersion 33
compileSdk 34

defaultConfig {
minSdkVersion 16
minSdk 16
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

Expand All @@ -46,12 +46,13 @@ android {
sourceCompatibility 1.8
targetCompatibility 1.8
}
}

dependencies {
def exoplayer_version = "2.18.7"
implementation "com.google.android.exoplayer:exoplayer-core:$exoplayer_version"
implementation "com.google.android.exoplayer:exoplayer-dash:$exoplayer_version"
implementation "com.google.android.exoplayer:exoplayer-hls:$exoplayer_version"
implementation "com.google.android.exoplayer:exoplayer-smoothstreaming:$exoplayer_version"
dependencies {
def exoplayer_version = "2.18.7"
implementation "com.google.android.exoplayer:exoplayer-core:$exoplayer_version"
implementation "com.google.android.exoplayer:exoplayer-dash:$exoplayer_version"
implementation "com.google.android.exoplayer:exoplayer-hls:$exoplayer_version"
implementation "com.google.android.exoplayer:exoplayer-smoothstreaming:$exoplayer_version"
}
}

1 change: 0 additions & 1 deletion just_audio/example/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
/build/

# Web related
lib/generated_plugin_registrant.dart

# Symbolication related
app.*.symbols
Expand Down
6 changes: 3 additions & 3 deletions just_audio/example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
namespace 'com.ryanheise.just_audio_example'
compileSdkVersion 33
compileSdk 34

lintOptions {
disable 'InvalidPackage'
Expand All @@ -35,8 +35,8 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.ryanheise.just_audio_example"
minSdkVersion 19
targetSdkVersion 33
minSdk flutter.minSdkVersion
targetSdk 34
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down

This file was deleted.

38 changes: 38 additions & 0 deletions just_audio/lib/just_audio.dart
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ class AudioPlayer {
bool _playInterrupted = false;
bool _platformLoading = false;
AndroidAudioAttributes? _androidAudioAttributes;
WebCrossOrigin? _webCrossOrigin;
final bool _androidApplyAudioAttributes;
final bool _handleAudioSessionActivation;

Expand Down Expand Up @@ -1196,6 +1197,29 @@ class AudioPlayer {
usage: audioAttributes.usage.value));
}

/// Set the `crossorigin` attribute on the `<audio>` element backing this
/// player instance on web (see
/// [HTMLMediaElement crossorigin](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/crossOrigin) ).
///
/// If [webCrossOrigin] is null (the initial state), the URL will be fetched
/// without CORS. If it is `useCredentials`, a CORS request will be made
/// exchanging credentials (via cookies/certificates/HTTP authentication)
/// regardless of the origin. If it is 'anonymous', a CORS request will be
/// made, but credentials are exchanged only if the URL is fetched from the
/// same origin.
Future<void> setWebCrossOrigin(WebCrossOrigin? webCrossOrigin) async {
if (_disposed) return;
if (!kIsWeb && !_isUnitTest()) return;

await (await _platform).setWebCrossOrigin(
SetWebCrossOriginRequest(
crossOrigin: webCrossOrigin == null
? null
: WebCrossOriginMessage.values[webCrossOrigin.index]),
);
_webCrossOrigin = webCrossOrigin;
}

/// Release all resources associated with this player. You must invoke this
/// after you are done with the player.
Future<void> dispose() async {
Expand Down Expand Up @@ -1446,6 +1470,11 @@ class AudioPlayer {
? ShuffleModeMessage.all
: ShuffleModeMessage.none));
if (checkInterruption()) return platform;
if (kIsWeb && _webCrossOrigin != null) {
await platform.setWebCrossOrigin(SetWebCrossOriginRequest(
crossOrigin: WebCrossOriginMessage.values[_webCrossOrigin!.index],
));
}
for (var audioEffect in _audioPipeline._audioEffects) {
await audioEffect._activate(platform);
if (checkInterruption()) return platform;
Expand Down Expand Up @@ -3486,6 +3515,9 @@ class DefaultShuffleOrder extends ShuffleOrder {
/// An enumeration of modes that can be passed to [AudioPlayer.setLoopMode].
enum LoopMode { off, one, all }

/// Possible values that can be passed to [AudioPlayer.setWebCrossOrigin].
enum WebCrossOrigin { anonymous, useCredentials }

/// The stand-in platform implementation to use when the player is in the idle
/// state and the native platform is deallocated.
class _IdleAudioPlayer extends AudioPlayerPlatform {
Expand Down Expand Up @@ -3583,6 +3615,12 @@ class _IdleAudioPlayer extends AudioPlayerPlatform {
return SetShuffleOrderResponse();
}

@override
Future<SetWebCrossOriginResponse> setWebCrossOrigin(
SetWebCrossOriginRequest request) async {
return SetWebCrossOriginResponse();
}

@override
Future<SetAutomaticallyWaitsToMinimizeStallingResponse>
setAutomaticallyWaitsToMinimizeStalling(
Expand Down
6 changes: 3 additions & 3 deletions just_audio/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: just_audio
description: A feature-rich audio player for Flutter. Loop, clip and concatenate any sound from any source (asset/file/URL/stream) in a variety of audio formats with gapless playback.
version: 0.9.37
version: 0.9.38
repository: https://github.com/ryanheise/just_audio/tree/minor/just_audio
issue_tracker: https://github.com/ryanheise/just_audio/issues
topics:
Expand All @@ -14,10 +14,10 @@ environment:
flutter: ">=3.10.0"

dependencies:
just_audio_platform_interface: ^4.2.2
just_audio_platform_interface: ^4.3.0
# just_audio_platform_interface:
# path: ../just_audio_platform_interface
just_audio_web: ^0.4.10
just_audio_web: ^0.4.11
# just_audio_web:
# path: ../just_audio_web
audio_session: ^0.1.14
Expand Down
4 changes: 4 additions & 0 deletions just_audio_background/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.0.1-beta.12

* Support setWebCrossOrigin.

## 0.0.1-beta.11

* Pass through missing API methods.
Expand Down
6 changes: 3 additions & 3 deletions just_audio_background/example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 33
compileSdk 34

lintOptions {
disable 'InvalidPackage'
Expand All @@ -34,8 +34,8 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.ryanheise.just_audio_example"
minSdkVersion 19
targetSdkVersion 33
minSdk flutter.minSdkVersion
targetSdk 34
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<!-- If targeting SDK 34 -->
<!-- <uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK"/> -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK"/>

<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion just_audio_background/example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:7.0.2'
classpath 'com.android.tools.build:gradle:7.3.0'
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
12 changes: 12 additions & 0 deletions just_audio_background/lib/just_audio_background.dart
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,13 @@ class _JustAudioPlayer extends AudioPlayerPlatform {
SetShuffleOrderRequest request) =>
_playerAudioHandler.customSetShuffleOrder(request);

@override
Future<SetWebCrossOriginResponse> setWebCrossOrigin(
SetWebCrossOriginRequest request) async {
_playerAudioHandler.customSetWebCrossOrigin(request);
return SetWebCrossOriginResponse();
}

@override
Future<SeekResponse> seek(SeekRequest request) =>
_playerAudioHandler.customPlayerSeek(request);
Expand Down Expand Up @@ -507,6 +514,11 @@ class _PlayerAudioHandler extends BaseAudioHandler
));
}

Future<SetWebCrossOriginResponse> customSetWebCrossOrigin(
SetWebCrossOriginRequest request) async {
return await (await _player).setWebCrossOrigin(request);
}

Future<ConcatenatingInsertAllResponse> customConcatenatingInsertAll(
ConcatenatingInsertAllRequest request) async {
final cat = _source!.findCat(request.id)!;
Expand Down
4 changes: 2 additions & 2 deletions just_audio_background/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
name: just_audio_background
description: An add-on for just_audio that supports background playback and media notifications.
homepage: https://github.com/ryanheise/just_audio/tree/master/just_audio_background
version: 0.0.1-beta.11
version: 0.0.1-beta.12
topics:
- audio
- sound
- player
- background

dependencies:
just_audio_platform_interface: ^4.2.2
just_audio_platform_interface: ^4.3.0
# just_audio_platform_interface:
# path: ../just_audio_platform_interface
audio_service: ^0.18.9
Expand Down
4 changes: 4 additions & 0 deletions just_audio_platform_interface/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 4.3.0

* Add setWebCrossOrigin for CORS on web (@danielwinkler).

## 4.2.2

* Add setAllowsExternalPlayback on iOS/macOS.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,12 @@ abstract class AudioPlayerPlatform {
throw UnimplementedError(
"androidEqualizerBandSetGain() has not been implemented.");
}

/// Sets the 'crossOrigin' attribute on the web audio element.
Future<SetWebCrossOriginResponse> setWebCrossOrigin(
SetWebCrossOriginRequest request) {
throw UnimplementedError("setWebCrossOrigin() has not been implemented.");
}
}

/// A data update communicated from the platform implementation to the Flutter
Expand Down Expand Up @@ -1485,3 +1491,13 @@ class AndroidEqualizerMessage extends AudioEffectMessage {
'parameters': parameters?.toMap(),
};
}

class SetWebCrossOriginRequest {
final WebCrossOriginMessage? crossOrigin;

SetWebCrossOriginRequest({required this.crossOrigin});
}

class SetWebCrossOriginResponse {}

enum WebCrossOriginMessage { anonymous, useCredentials }
2 changes: 1 addition & 1 deletion just_audio_platform_interface/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: A common platform interface for the just_audio plugin. Different pl
homepage: https://github.com/ryanheise/just_audio/tree/master/just_audio_platform_interface
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
version: 4.2.2
version: 4.3.0

dependencies:
flutter:
Expand Down
5 changes: 5 additions & 0 deletions just_audio_web/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.4.11

* Bump package:web upper bound to <0.6.0
* Add AudioPlayer.setWebCrossOrigin for CORS on web (@danielwinkler).

## 0.4.10

* Migrate to package:web.
Expand Down
Loading

0 comments on commit 173c0d1

Please sign in to comment.