Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
400670f
Fix compile error
mehmetf Sep 20, 2018
2ab168e
Merge pull request #58 from mehmetf/master
mehmetf Sep 20, 2018
7faa785
Cleanup java warnings. Update Dart SDK requirement
mehmetf Sep 20, 2018
24d027b
Rev the version
mehmetf Sep 20, 2018
e87c5f7
Merge pull request #59 from mehmetf/master
mehmetf Sep 20, 2018
4358e7a
updates the example app
Nov 18, 2018
8bb7c3d
first pass at converting the objc code to swift
mattetti Mar 26, 2020
57f3e2d
clean things up and fix obvious bugs
mattetti Mar 27, 2020
056f76a
another quick cleanup
mattetti Mar 27, 2020
39caf3b
add support for macOS
mattetti Mar 27, 2020
fd76df5
Merge pull request #114 from mattetti/swiftify
rxlabz Apr 2, 2020
63cd966
Merge pull request #115 from mattetti/macos
rxlabz Apr 2, 2020
3c545a6
update example urls
rxlabz Apr 2, 2020
8e44c2b
fix conditional import
rxlabz Apr 2, 2020
1cdf03a
Update CHANGELOG & num version
rxlabz Apr 2, 2020
28737c9
0.7.0 : add web support
rxlabz Apr 2, 2020
2168450
README
rxlabz Apr 2, 2020
8ff9629
update README, descriptions, screenshot
rxlabz Apr 2, 2020
2dc0cf0
changelog
rxlabz Apr 2, 2020
fc3f45d
licence
rxlabz Apr 2, 2020
0e989b4
screenshots
rxlabz Apr 2, 2020
4ba86fe
minor
rxlabz Apr 2, 2020
7a60a15
Move minSdk to build.gradle
nstrelow Apr 3, 2020
ca0deac
Merge pull request #117 from nstrelow/master
rxlabz Apr 3, 2020
61bc4cc
Android : new FlutterPlugin API & AndroidX migration
rxlabz Apr 3, 2020
b38c326
versioning
rxlabz Apr 3, 2020
9366daa
update mp3 sample url
rxlabz Apr 3, 2020
b862347
web export
rxlabz Apr 3, 2020
3b4e0b5
Fix error building iOS due to incorrect case when referencing timeobs…
josh-burton Apr 6, 2020
67ce95d
Update SwiftAudioplayerPlugin.swift
mhatout Apr 6, 2020
f1eaf64
Merge pull request #119 from athornz/ios-timeobservers-fix
rxlabz Apr 6, 2020
13d1af3
Merge branch 'master' of github.com:rxlabz/audioplayer
rxlabz Apr 6, 2020
fdfff6f
Merge pull request #120 from mhatout/master
rxlabz Apr 6, 2020
ce84b40
Merge branch 'master' of github.com:rxlabz/audioplayer
rxlabz Apr 6, 2020
a72b404
add a no op audioplayer_web to avoid compilation error when compiling…
rxlabz Apr 6, 2020
d0cc9ae
CHANGELOG, README + minors
rxlabz Apr 6, 2020
d7e2d85
version num
rxlabz Apr 6, 2020
9517b31
changelog
rxlabz Apr 6, 2020
d73f74e
Fix bugs introduced by v2 migration
lidongze91 Apr 22, 2020
540ba91
Update README.md
rxlabz Oct 15, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
.DS_Store
**/.DS_Store
.atom/
.idea
.packages
.pub/
.dart_tool/
build/
ios/.generated/
packages
pubspec.lock
**/.packages
**/.pub/
**/.dart_tool/
**/build/
**/ios/.generated/
**/packages
**/pubspec.lock

Podfile
Podfile.lock
Pods/
.symlinks/
**/Pods/
**/.symlinks/
**/Flutter/App.framework/
**/Flutter/Flutter.framework/
**/Flutter/Generated.xcconfig
Expand All @@ -21,7 +21,7 @@ ServiceDefinitions.json
xcuserdata/

local.properties
.gradle/
**/.gradle/
gradlew
gradlew.bat
gradle-wrapper.jar
Expand All @@ -30,4 +30,8 @@ gradle-wrapper.jar
GeneratedPluginRegistrant.h
GeneratedPluginRegistrant.m
GeneratedPluginRegistrant.java
build/
example/.flutter-plugins-dependencies
example/ios/Flutter/flutter_export_environment.sh

.flutter-plugins
.flutter-plugins-dependencies
65 changes: 39 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
# :warning: DEPRECATED

Check out

- [audioplayers](https://pub.dev/packages/audioplayers)
- [just_audio](https://pub.dev/packages/just_audio)
___
# AudioPlayer

A Flutter audio plugin (ObjC/Java) to play remote or local audio files
A Flutter audio plugin (Swift/Java) to play remote or local audio files on iOS / Android / MacOS and Web.

[Online demo](https://rxlabz.github.io/audioplayer/)

## Features

- [x] Android & iOS
- [x] play (remote file)
- [x] Android / iOS / MacOS / Web
- [x] play remote file
- [x] play local file ( not for the web)
- [x] stop
- [x] pause
- [x] onComplete
- [x] onDuration / onCurrentPosition
- [x] seek
- [x] mute

![screenshot](https://www.evernote.com/shard/s1/sh/c9e2e0dc-4e1b-4797-b23f-2bdf0f6f3387/d1138680d3b4bdcd/res/1afa2507-2df2-42ef-a840-d7f3519f5cb3/skitch.png?resizeSmall&width=320)
![screenshot](https://rxlabz.github.io/audioplayer/audioplayer.png)

## Usage

Expand All @@ -27,38 +37,26 @@ To use this plugin :
dependencies:
flutter:
sdk: flutter
audioplayer:
audioplayer: 0.8.1
audioplayer_web: 0.7.1
```

- Instantiate an AudioPlayer instance

```dart
//...
AudioPlayer audioPlugin = new AudioPlayer();
AudioPlayer audioPlugin = AudioPlayer();
//...
```

### Player Controls

```dart
Future<void> play() async {
await audioPlayer.play(kUrl);
setState(() => playerState = PlayerState.playing);
}

Future<void> pause() async {
await audioPlayer.pause();
setState(() => playerState = PlayerState.paused);
}

Future<void> stop() async {
await audioPlayer.stop();
setState(() {
playerState = PlayerState.stopped;
position = new Duration();
});
}
audioPlayer.play(url);

audioPlayer.pause();

audioPlayer.stop();
```

### Status and current position
Expand Down Expand Up @@ -91,9 +89,10 @@ _audioPlayerStateSubscription = audioPlayer.onPlayerStateChanged.listen((s) {

Do not forget to cancel all the subscriptions when the widget is disposed.


## iOS

## :warning: iOS App Transport Security
### :warning: iOS App Transport Security

By default iOS forbids loading from non-https url. To cancel this restriction edit your .plist and add :

Expand All @@ -104,12 +103,26 @@ By default iOS forbids loading from non-https url. To cancel this restriction ed
<true/>
</dict>
```

### Background mode

cf. [enable background audio](https://developer.apple.com/documentation/avfoundation/media_assets_playback_and_editing/creating_a_basic_video_player_ios_and_tvos/enabling_background_audio)

## MacOS

Add this to entitlements files ( cf. [DebugProfile.entitlements](example/macos/Runner/DebugProfile.entitlements) )
```xml
<key>com.apple.security.network.client</key>
<true/>
```

cf. [Flutter MacOS security](https://github.com/google/flutter-desktop-embedding/blob/master/macOS-Security.md)

## Troubleshooting

- If you get a MissingPluginException, try to `flutter build apk` on Android, or `flutter build ios`
- to use the plugin in a ObjC iOS project, add 'use_frameworks!' to your podfile cf. [example](https://github.com/rxlabz/audioplayer/blob/master/example/ios/Podfile)

## Getting Started
## Getting Started with Flutter

For help getting started with Flutter, view our online
[documentation](http://flutter.io/).
Expand Down
1 change: 0 additions & 1 deletion android/gradle.properties

This file was deleted.

7 changes: 0 additions & 7 deletions android/src/main/AndroidManifest.xml

This file was deleted.

9 changes: 9 additions & 0 deletions audioplayer/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.DS_Store
.dart_tool/

.packages
.pub/

build/

.metadata
22 changes: 22 additions & 0 deletions CHANGELOG.md → audioplayer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
# Changelog

## 0.8.1
- iOS : enable audio output to speakers thanks @mhatout
- fixes iOS 'timeobservers' typo thanks @athornz

## 0.8.0
- Android : new FlutterPlugin API & AndroidX migration

## 0.7.0
- add Web support

## 0.6.0
- switch to Swift thanks @matteti #114
- add MacOS support thanks @matteti #115

## 0.5.2
- fix objC warning
- updated example

## 0.5.1
- Allow Dart 2 SDK
- Fix java lint warnings.

## 0.5.0
- BREAKING Change: No more separate handlers for communicating the state of the player. Instead we rely on streams to publish state changes and position updates.
- Code formatting and flow improvements. Preparation for testing.
Expand Down
File renamed without changes.
123 changes: 123 additions & 0 deletions audioplayer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# AudioPlayer

A Flutter audio plugin (Swift/Java) to play remote or local audio files on iOS / Android / MacOS / Web.

[Online demo](https://rxlabz.github.io/audioplayer/)

## Features

- [x] Android / iOS / MacOS / Web
- [x] play remote file
- [x] play local file ( not for the web)
- [x] stop
- [x] pause
- [x] onComplete
- [x] onDuration / onCurrentPosition
- [x] seek
- [x] mute

![screenshot](https://rxlabz.github.io/audioplayer/audioplayer.png)

## Usage

[Example](https://github.com/rxlabz/audioplayer/blob/master/example/lib/main.dart)

To use this plugin :

- Add the dependency to your [pubspec.yaml](https://github.com/rxlabz/audioplayer/blob/master/example/pubspec.yaml) file.

```yaml
dependencies:
flutter:
sdk: flutter
audioplayer: 0.8.1
audioplayer_web: 0.7.1
```

- Instantiate an AudioPlayer instance

```dart
//...
AudioPlayer audioPlugin = AudioPlayer();
//...
```

### Player Controls

```dart
audioPlayer.play(url);

audioPlayer.pause();

audioPlayer.stop();
```

### Status and current position

The dart part of the plugin listen for platform calls :

```dart
//...
_positionSubscription = audioPlayer.onAudioPositionChanged.listen(
(p) => setState(() => position = p)
);

_audioPlayerStateSubscription = audioPlayer.onPlayerStateChanged.listen((s) {
if (s == AudioPlayerState.PLAYING) {
setState(() => duration = audioPlayer.duration);
} else if (s == AudioPlayerState.STOPPED) {
onComplete();
setState(() {
position = duration;
});
}
}, onError: (msg) {
setState(() {
playerState = PlayerState.stopped;
duration = new Duration(seconds: 0);
position = new Duration(seconds: 0);
});
});
```

Do not forget to cancel all the subscriptions when the widget is disposed.


## iOS

### :warning: iOS App Transport Security

By default iOS forbids loading from non-https url. To cancel this restriction edit your .plist and add :

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

### Background mode

cf. [enable background audio](https://developer.apple.com/documentation/avfoundation/media_assets_playback_and_editing/creating_a_basic_video_player_ios_and_tvos/enabling_background_audio)

## MacOS

Add this to entitlements files ( cf. [DebugProfile.entitlements](example/macos/Runner/DebugProfile.entitlements) )
```xml
<key>com.apple.security.network.client</key>
<true/>
```

cf. [Flutter MacOS security](https://github.com/google/flutter-desktop-embedding/blob/master/macOS-Security.md)

## Troubleshooting

- If you get a MissingPluginException, try to `flutter build apk` on Android, or `flutter build ios`

## Getting Started with Flutter

For help getting started with Flutter, view our online
[documentation](http://flutter.io/).

For help on editing plugin code, view the [documentation](https://flutter.io/platform-plugins/#edit-code).
4 changes: 0 additions & 4 deletions android/.gitignore → audioplayer/android/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,3 @@
.DS_Store
/build
/captures

/gradle
/gradlew
/gradlew.bat
17 changes: 11 additions & 6 deletions android/build.gradle → audioplayer/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,32 +1,37 @@
group 'bz.rxla.audioplayer'
version '1.0-SNAPSHOT'
version '1.0'

buildscript {
repositories {
google()
jcenter()
}

dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
classpath 'com.android.tools.build:gradle:3.5.0'
}
}

allprojects {
rootProject.allprojects {
repositories {
google()
jcenter()
}
}

apply plugin: 'com.android.library'

android {
compileSdkVersion 25
buildToolsVersion '25.0.3'
compileSdkVersion 28

defaultConfig {
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
minSdkVersion 16
}
lintOptions {
disable 'InvalidPackage'
}
}

dependencies {
implementation 'com.android.support:support-annotations:28.0.0'
}
4 changes: 4 additions & 0 deletions audioplayer/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
org.gradle.jvmargs=-Xmx1536M
android.enableR8=true
android.useAndroidX=true
android.enableJetifier=true
Loading