Giter Site home page Giter Site logo

rxlabz / audioplayer Goto Github PK

View Code? Open in Web Editor NEW
492.0 17.0 189.0 12.87 MB

A flutter plugin to play audio files iOS / Android / MacOS / Web ( Swift/Java )

Home Page: https://pub.dartlang.org/packages/audioplayer

Java 16.44% Ruby 6.46% Objective-C 4.51% Dart 46.00% Swift 22.26% Shell 1.22% HTML 3.12%
flutter flutter-plugin audio-player android dartlang

audioplayer's Introduction

Hi there ๐Ÿ‘‹

audioplayer's People

Contributors

alanrussian avatar gdcolella avatar josh-burton avatar lidongze91 avatar mattetti avatar mehmetf avatar mhatout avatar mindon avatar mit-mit avatar nstrelow avatar oakes avatar rxlabz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

audioplayer's Issues

Local file

I have tried to play a local file but couldn't seem to get this working. Is this supported?

I tried something like the following
await audioPlayer.play('assets/sloths.mp3', isLocal: true);
with the assets directory directly off my main flutter directory

(massive caveat: I am only two days old with flutter and dart! Keep up the good work ๐Ÿ‘ )

Errors
E/ExtMediaPlayer-JNI(11260): env->IsInstanceOf fails
E/MediaPlayer-JNI(11260): JNIMediaPlayerFactory: bIsQCMediaPlayerPresent 0
E/ExtMediaPlayer-JNI(11260): env->IsInstanceOf fails
E/MediaPlayer-JNI(11260): JNIMediaPlayerFactory: bIsQCMediaPlayerPresent 0
W/System.err(11260): java.io.IOException: setDataSource failed.
W/System.err(11260): at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1095)
W/System.err(11260): at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1041)

issues playing audioplayer in a widget on several page widgets

I am having issues playing audioplayer in a widget: I have all the initialization code in the initState of the widhet it seems that the audioplayer is initialized everytime the widget is opened in another widget, and remains initialized, which is OK on one hand, because it continues to play when I move from one page to another, but not OK because it is creating more and more audioplayers. I noticed it because I am using a subscription stream to send a message that the audio is playing, and more and more of these messages came through.

Am I doing something wrong? Should I do the initialization in a different way? Or is it just that the objects linger around and wait to be discarded in some kind of garbage collection?

mediaPlayer keeps going null?

I've created a simple audio recorder here: I tend to find that my app will crash due to the mediaplayer going null (tested on a Google Pixel phone) when trying to call seek. For some reason this only happens when the phone is plugged into my computer.

The relavant code is in this file:
https://github.com/LarsDu/simple_flutter_audio_recorder/blob/master/lib/audio_play_bar.dart
The error:

W/MediaPlayer( 1997): See the documentation of setAudioStreamType() for what to use instead with android.media.AudioAttributes to qualify your playback use case
V/MediaPlayer( 1997): resetDrmState:  mDrmInfo=null mDrmProvisioningThread=null mPrepareDrmInProgress=false mActiveDrmScheme=false
V/MediaPlayer( 1997): cleanDrmObj: mDrmObj=null mDrmSessionId=null
W/MediaPlayer( 1997): mediaplayer went away with unhandled events

Support of Obj-C version?

I am trying to test audioplayer plugin with the FriendlyChat source.

When I do "edit/convert/To Current Swift Syntax" and I selected all items in this screen

and I get this message

then I add plugins to yaml and run, I get error

Launching lib/main.dart on iPhone SE in debug mode...

Running pod install...

Error running pod install: Exit code 1 from: pod install

Error launching application on iPhone SE.

How to play from assets in flutter app

I have added a mp3 file in asset and trying to play it as local file from the play method. But it is not getting played. what can be the reason?
I am also getting the error of 'E/MediaPlayerNative(12813): start called in state 0, mPlayer(0x0)
E/MediaPlayerNative(12813): Attempt to call getDuration in wrong state: mPlayer=0x0, mCurrentState=0'

Playing from assets

I can't seem to figure out how to play a file from flutter assets, is it possible?

Seek ios issue

Hi!!

When I try to fordward the audio with the seek method I get the following error and the app has a crash:

ios -> onTimeInterval... SEEK TO >>>> 2101.401785349884 iOS => call seek seek Lost connection to device. *** First throw call stack: ( 0 CoreFoundation 0x0000000107a9212b __exceptionPreprocess + 171 1 libobjc.A.dylib 0x0000000106ce1f41 objc_exception_throw + 48 2 CoreFoundation 0x0000000107b13024 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132 3 CoreFoundation 0x0000000107a14f78 ___forwarding___ + 1432 4 CoreFoundation 0x0000000107a14958 _CF_forwarding_prep_0 + 120 5 Runner 0x0000000104eeb378 __45-[AudioplayerPlugin handleMethodCall:result:]_block_invoke.51 + 104 6 Runner 0x0000000104eeac81 -[AudioplayerPlugin handleMethodCall:result:] + 1169 7 Flutter 0x0000000104fc2020 __45-[FlutterMethodChannel setMethodCa<โ€ฆ>

Background mode

background play is not working properly,in debug mode it is working fine but in release mode it is not working,do we need to add any permissions?

IOS connection lost

First I've downloaded the file then click on Play Local

*** First throw call stack: ( 0 CoreFoundation 0x000000010409212b __exceptionPreprocess + 171 1 libobjc.A.dylib 0x00000001046a9f41 objc_exception_throw + 48 2 CoreFoundation 0x0000000104113024 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132 3 CoreFoundation 0x0000000104014f78 ___forwarding___ + 1432 4 CoreFoundation 0x0000000104014958 _CF_forwarding_prep_0 + 120 5 audioplayer 0x000000010394e04a -[AudioplayerPlugin togglePlay:isLocal:] + 170 6 audioplayer 0x000000010394da93 __45-[AudioplayerPlugin handleMethodCall:result:]_block_invoke + 563 7 audioplayer 0x000000010394d691 -[AudioplayerPlugin handleMethodCall:result:] + 1169 8 Flutte<โ€ฆ> Lost connection to device.

I like this plugin I want to make an app around it !

Loading next track. Any ideas?

I'm able to load the next track if the prior track ends, employing onComplete

  void onComplete() async {
    currentTrack++;
    String url = tracks[currentTrack]['url'];
    final result = await audioPlayer.play(url);
    if (result == 1)
      setState(() {
        position = duration;
        print('_AudioAppState.play... PlayerState.playing');
      });
  }

However if I add a next button

          new IconButton(
              onPressed: () => next(),
              iconSize: 64.0,
              icon: new Icon(Icons.skip_next),
              color: Colors.cyan),

Which invokes a next() method (using the EXACT SAME code as onComplete)

  Future next() async {
    currentTrack++;
    String url = tracks[currentTrack]['url'];
    final result = await audioPlayer.play(url);
    if (result == 1)
      setState(() {
        position = duration;
        print('_AudioAppState.play... PlayerState.playing');
      });
  }

The next track will play, but the duration text remains frozen, as does the play button.

Any thoughts? Thanks!

Recording ability

I've been looking for a way to save the stream to a file. Is there a way that the byte stream can be accessed so it can be written?

Requires SDK version >=1.8.0 <2.0.0, version solving failed.

Hi there,

I'm currently getting the error:

Because the app depends on audioplayer any which requires SDK version >=1.8.0 <2.0.0, version solving failed.
pub get failed (1)
exit code 1

When adding: audioplayer: to my pubspec.yaml.

FYI, my current Dart version:

The current Dart SDK version is 2.1.0-dev.1.0.flutter-69fce633b7 - which obviously explains the message above, however is it possible to have the SDK requirements updated?

Thanks!

Play mp3 from Asset

Hello, do anyone know how can I play a WAV or MP3 from an asset? - I've tried using isLocal: true with no luck.

thanks

[Android]Player resets its position several times on 3G network

Hi!

I ran the demo available to test the plugin (Android 6.0.1) and noticed a strange behavior.

When I am connected to a slow network (I am testing with 3G network), the player resets to position 0:00:00 even though it has already loaded a few seconds of audio content. The player repeats this behavior several times.

When I am connected on a fast network, this behavior does not happen :)

Could someone help me with this problem, please?

I've attached a video for better understanding:
issue_video.zip

Logs:

02-26 19:15:11.407 I/FlutterActivityDelegate: onResume setting current activity to this
02-26 19:15:11.418 D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
02-26 19:15:11.462 I/OpenGLRenderer: Initialized EGL, version 1.4
02-26 19:15:11.905 I/flutter: Observatory listening on http://127.0.0.1:54132/
02-26 19:15:16.896 I/MediaHTTPConnection: proxyName: 0.0.0.0 0
02-26 19:15:19.945 D/MediaPlayer: setSubtitleAnchor in MediaPlayer
02-26 19:15:19.992 I/flutter: _AudioAppState.setDurationHandler => d 0:02:27.305000
02-26 19:15:20.025 I/flutter: _AudioAppState.setPositionHandler => p 0:00:00.000000
02-26 19:15:20.226 I/flutter: _AudioAppState.setPositionHandler => p 0:00:00.008000
02-26 19:15:20.432 I/flutter: _AudioAppState.setPositionHandler => p 0:00:00.004000
02-26 19:15:20.627 I/flutter: _AudioAppState.setPositionHandler => p 0:00:00.001000
02-26 19:15:20.829 I/flutter: _AudioAppState.setPositionHandler => p 0:00:00.007000
02-26 19:15:21.032 I/flutter: _AudioAppState.setPositionHandler => p 0:00:00.003000
02-26 19:15:21.238 I/flutter: _AudioAppState.setPositionHandler => p 0:00:00.009000
02-26 19:15:21.445 I/flutter: _AudioAppState.setPositionHandler => p 0:00:00.002000
02-26 19:15:21.645 I/flutter: _AudioAppState.setPositionHandler => p 0:00:00.008000
02-26 19:15:21.847 I/flutter: _AudioAppState.setPositionHandler => p 0:00:00.004000
02-26 19:15:22.046 I/flutter: _AudioAppState.setPositionHandler => p 0:00:00.082000
02-26 19:15:22.255 I/flutter: _AudioAppState.setPositionHandler => p 0:00:00.186000
02-26 19:15:22.459 I/flutter: _AudioAppState.setPositionHandler => p 0:00:00.390000
02-26 19:15:22.660 I/flutter: _AudioAppState.setPositionHandler => p 0:00:00.592000
02-26 19:15:22.858 I/flutter: _AudioAppState.setPositionHandler => p 0:00:00.789000
02-26 19:15:23.061 I/flutter: _AudioAppState.setPositionHandler => p 0:00:00.990000
02-26 19:15:23.260 I/flutter: _AudioAppState.setPositionHandler => p 0:00:01.192000
02-26 19:15:23.465 I/flutter: _AudioAppState.setPositionHandler => p 0:00:01.397000
02-26 19:15:23.666 I/flutter: _AudioAppState.setPositionHandler => p 0:00:01.599000
02-26 19:15:23.870 I/flutter: _AudioAppState.setPositionHandler => p 0:00:01.804000
02-26 19:15:24.072 I/flutter: _AudioAppState.setPositionHandler => p 0:00:02.006000
02-26 19:15:24.273 I/flutter: _AudioAppState.setPositionHandler => p 0:00:02.208000
02-26 19:15:24.475 I/flutter: _AudioAppState.setPositionHandler => p 0:00:00.036000
02-26 19:15:24.676 I/flutter: _AudioAppState.setPositionHandler => p 0:00:00.169000

Thank you!

iOS - proper stop code

Stop method was just pausing and moving the pointer back to the beginning. On streaming media this was leading to an issue of playing from the beginning of the cached part.

I think this should be a better replacement

-(void) stop {
  if(isPlaying){
    //[ self pause ];
    //[ self seek: CMTimeMake(0, 1) ];
    
    [player replaceCurrentItemWithPlayerItem: nil];

    lastUrl = nil; // In case play the same url/file again, AVPlayerItem needs to be recreated.
    isPlaying = false;
    NSLog(@"stop");
  }
}

iOS - Physical volume buttons have no effect on audio volume

Physical volume buttons did not have any effect on the audio volume. These codes I've stumbled on StackOverflow seem like working. I have nearly zero knowledge on ios programming. I don't know if it's the right place, but I've added the to - (id) init method.

It would be good to have system volume getter and setter methods too. So it will be easier to add onscreen volume controls, like a volume slider.

- (id)init {
  self = [super init];
  if (self) {
      players = [[NSMutableDictionary alloc] init];
  }

  AudioSessionInitialize (NULL, NULL, NULL, NULL);
  UInt32 sessionCategory = kAudioSessionCategory_AmbientSound;
  AudioSessionSetProperty (kAudioSessionProperty_AudioCategory, sizeof (sessionCategory), &sessionCategory);
  AudioSessionSetActive (true);

  return self;
}

https://stackoverflow.com/questions/18541139/ios-avaudioplayer-volume-control

https://stackoverflow.com/questions/16474771/cannot-control-volume-of-avaudioplayer-via-hardware-buttons-when-audiosessionact

Does audioplayer support living streaming audio

In this case, the audio is sent with Transfer-Encoding: chunked and no Content-length. I am trying that and getting the following error:

V/MediaPlayer-JNI( 5451): native_setup
V/MediaPlayer( 5451): constructor
V/MediaPlayer( 5451): setListener
V/MediaPlayer-JNI( 5451): setAudioStreamType: 3
V/MediaPlayer( 5451): MediaPlayer::setAudioStreamType
V/MediaPlayer( 5451): setVideoSurfaceTexture
V/MediaPlayer( 5451): prepare
D/MediaHTTPConnection( 5451): setReadTimeOut =  30000ms
D/MediaHTTPConnection( 5451): setReadTimeout with 30000ms
I/System.out( 5451): (HTTPLog)-Static: isSBSettingEnabled false
I/System.out( 5451): (HTTPLog)-Static: isSBSettingEnabled false
I/MediaHTTPConnection( 5451): response code = 200
V/MediaHTTPConnection( 5451): mTotalSize is -1
V/MediaPlayer( 5451): message received msg=100, ext1=1, ext2=-2147483648
E/MediaPlayer( 5451): error (1, -2147483648)
V/MediaPlayer( 5451): signal application thread
V/MediaPlayer( 5451): prepare complete - status=1
D/AUDIO   ( 5451): media prepare ERROR
W/System.err( 5451): java.io.IOException: Prepare failed.: status=0x1
W/System.err( 5451): 	at android.media.MediaPlayer._prepare(Native Method)
W/System.err( 5451): 	at android.media.MediaPlayer.prepare(MediaPlayer.java:1408)
W/System.err( 5451): 	at bz.rxla.audioplayer.AudioplayerPlugin.play(AudioplayerPlugin.java:92)
W/System.err( 5451): 	at bz.rxla.audioplayer.AudioplayerPlugin.onMethodCall(AudioplayerPlugin.java:44)
W/System.err( 5451): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:191)
W/System.err( 5451): 	at io.flutter.view.FlutterNativeView.handlePlatformMessage(FlutterNativeView.java:128)
W/System.err( 5451): 	at android.os.MessageQueue.nativePollOnce(Native Method)
W/System.err( 5451): 	at android.os.MessageQueue.next(MessageQueue.java:323)
W/System.err( 5451): 	at android.os.Looper.loop(Looper.java:136)
W/System.err( 5451): 	at android.app.ActivityThread.main(ActivityThread.java:6682)
W/System.err( 5451): 	at java.lang.reflect.Method.invoke(Native Method)
W/System.err( 5451): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
W/System.err( 5451): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
W/System.err( 5451): 	at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:102)
V/MediaPlayer( 5451): getDuration_l
E/MediaPlayer( 5451): Attempt to call getDuration in wrong state: mPlayer=0xc3869f40, mCurrentState=0
V/MediaPlayer( 5451): message received msg=100, ext1=-38, ext2=0
E/MediaPlayer( 5451): error (-38, 0)
V/MediaPlayer( 5451): callback application
V/MediaPlayer( 5451): back from callback
V/MediaPlayer-JNI( 5451): getDuration: 0 (msec)
V/MediaPlayer-JNI( 5451): start
V/MediaPlayer( 5451): start
E/MediaPlayer( 5451): start called in state 0, mPlayer(0xc3869f40)
V/MediaPlayer( 5451): message received msg=100, ext1=-38, ext2=0
E/MediaPlayer( 5451): error (-38, 0)
V/MediaPlayer( 5451): callback application
V/MediaPlayer( 5451): back from callback
E/MediaPlayer( 5451): Error (-38,0)
V/MediaPlayer-JNI( 5451): stop
V/MediaPlayer( 5451): stop
E/MediaPlayer( 5451): stop called in state 0, mPlayer(0xc3869f40)
V/MediaPlayer( 5451): message received msg=100, ext1=-38, ext2=0
E/MediaPlayer( 5451): error (-38, 0)
V/MediaPlayer( 5451): callback application
V/MediaPlayer( 5451): back from callback
V/MediaPlayer-JNI( 5451): release
V/MediaPlayer( 5451): setListener
V/MediaPlayer( 5451): disconnect
V/MediaPlayer( 5451): destructor
V/MediaPlayer( 5451): disconnect
I/Choreographer( 5451): Skipped 349 frames!  The application may be doing too much work on its main thread.
W/MediaPlayer( 5451): mediaplayer went away with unhandled events
W/MediaPlayer( 5451): mediaplayer went away with unhandled events

Audio player unresponsive after stopping and creating new instance in a new isolate

I can't really explain this well in the short title.
I'm using the ryanheise/audio_service plugin.
This plugin launches an isolate for background dart code execution upon starting the audio service. In this isolate code (which I'll refer to as an "audio task") I implement callbacks and start, pause play, etc. an AudioPlayer instance. If, however, I stop the audio task, and start a new one (creating a new AudioPlayer instance in a new isolate), I can start playback okay, but nothing else works. I can't play, pause or stop the player. The futures for the AudioPlayer methods do finish, though. The method calls don't broadcast anything in the onPlayerStateChanged stream, either.

If you need my code to debug, I'd happily put up a private repo.

Pause stops instead of pause

I copied, pasted (and modified the names a bit) this code from here:

void _pause() async {
  final result = await player.pause();
  if (result == 1) setState(() => playerState = PlayerState.paused);
}

but player starts from the start when following is invoked:

void _play() async {
  final result = await player.play(kUrl);
  if (result == 1) setState(() => playerState = PlayerState.playing);
}

I am using Android 7.1.1 on Moto G5S to test.

Console message on pause:
W/MediaPlayer(24746): mediaplayer went away with unhandled events

New Warning Produced by Android Runtime

W/MediaPlayer(29189): Use of stream types is deprecated for operations other than volume control
W/MediaPlayer(29189): See the documentation of setAudioStreamType() for what to use instead with android.media.AudioAttributes to qualify your playback use case

Play bytes

Is there a way to play bytes directly?

Play on TV

I'm trying to play a mp3 file in TV emulator. I've tried with Oreo and Nougat. An exception is throw when I try to play the file.

W/MediaPlayer( 4085): Use of stream types is deprecated for operations other than volume control
W/MediaPlayer( 4085): See the documentation of setAudioStreamType() for what to use instead with android.media.AudioAttributes to qualify your playback use case
V/MediaHTTPService( 4085): MediaHTTPService(android.media.MediaHTTPService@952a13f): Cookies: null
V/MediaHTTPService( 4085): makeHTTPConnection: CookieManager created: java.net.CookieManager@b0a0a0c
V/MediaHTTPService( 4085): makeHTTPConnection(android.media.MediaHTTPService@952a13f): cookieManager: java.net.CookieManager@b0a0a0c Cookies: null

Play audio in Lock-screen...

Is there a way to play the audio in the Lock-Screen as background? User taps home button but need the audio to keep playing.

Thanks.

Buffering state for stream URLs

Is there any way to detect that the audio player is buffering audio when requesting it to play from a URL?

As it takes a while for the audio to start playing, I would like to show a buffering animation to the user to indicate that the buffering is indeed taking place.

I would have expected there to be a state for this in the AudioPlayerState enum, but this does not seem to exist.

Warning: Compilation warning

Note: /home/thinkdigital/SDKs/flutter/.pub-cache/hosted/pub.dartlang.org/audioplayer-0.5.0/android/src/main/java/bz/rxla/audioplayer/AudioplayerPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

Failed assertion: line 81 pos 16: '_state == AudioPlayerState.PLAYING': is not true

Hi,

I'm building a messaging app and I'm getting the error on the title line when playing a local file. I'm calling the audioPlayer.play() withing the message element. Since there are a lot of them I'm building the AudioPlayer object when tapping on an audio message and than trying to dispose it afterwards. In doing so the audio does play but the app crashes right afterwards with the error mentioned above. Any help is greatly appreciated.

# Here I initialized the AudioPlayer
audioPlayer = new AudioPlayer();

# Here I play the audio file, it crashes here 
await audioPlayer.play(_audioPath, isLocal: true);
setState(() => playerState = PlayerState.playing);

[iOS] audio stops playing in background

I tried the example app on a real iPhone device. When I switch the phone off audio stops playing. When I switch it on again it continue playing.

Do you have any hints?

I added audio to the UIBackgroundModes in the example/ios/Runner/Info.plist but it doesn't fixed the issue.

Audio Speed

I am rewriting an app in Flutter and looking for an audio player that allows the user to set the play back speed. It looks like this one does not allow the play back speed to the changed. Would you be open to adding play back speed as an option, or be willing to let me add it? It would be an android only option.

Audio only playing through headphones (never through speakers)

Does anyone know why this might be happening? I have tried to use this package on multiple ios devices and the sound only plays if there are headphones attached. Works fine on android. Is this some sort of permissions issue?

My only guess is that the file type (mp3) is only able to play through headphones. I am downloading mp3 files from firebase and playing them locally. My log messages look the same whether the headphones are plugged in or not.

With headphones, sound plays, and I get these logs:
flutter: attempting to play /var/mobile/Containers/Data/Application/1A17D73F-0130-4A6B-A1F4-B44ECAB4EF3E/Documents/English_mit_filler_David.mp3
iOS => call play
iOS => playerId dd4d9d29-2188-4795-abfb-6d785c6c19a7
play!
isLocal: 1 1
volume: 1.000000 1
togglePlay /var/mobile/Containers/Data/Application/1A17D73F-0130-4A6B-A1F4-B44ECAB4EF3E/Documents/English_mit_filler_David.mp3
ios -> updateDuration...nan
ios -> onTimeInterval...
flutter: _AudioAppState.setPositionHandler => p 0:00:00.000000
ios -> onTimeInterval...
player status: 1
ios -> updateDuration...19.435102
ios -> invokechannel
flutter: _AudioAppState.setPositionHandler => p 0:00:00.000000
ios -> onTimeInterval...
ios -> onTimeInterval...
flutter: _AudioAppState.setDurationHandler => d 0:00:19.435000
flutter: _AudioAppState.setPositionHandler => p 0:00:00.000000
flutter: _AudioAppState.setPositionHandler => p 0:00:00.000000
ios -> onTimeInterval...
flutter: _AudioAppState.setPositionHandler => p 0:00:00.200000
ios -> onTimeInterval...
flutter: _AudioAppState.setPositionHandler => p 0:00:00.401000
ios -> onTimeInterval...
flutter: _AudioAppState.setPositionHandler => p 0:00:00.600000
ios -> onTimeInterval...

Without headphones, no sound in speakers, and I get these logs:
flutter: attempting to play /var/mobile/Containers/Data/Application/1A17D73F-0130-4A6B-A1F4-B44ECAB4EF3E/Documents/English_mit_filler_Dropbox.mp3
iOS => call play
iOS => playerId 60dc6e8c-4619-4abb-812d-33dcb03f23a8
play!
isLocal: 1 1
volume: 1.000000 1
togglePlay /var/mobile/Containers/Data/Application/1A17D73F-0130-4A6B-A1F4-B44ECAB4EF3E/Documents/English_mit_filler_Dropbox.mp3
ios -> updateDuration...nan
ios -> onTimeInterval...
ios -> onTimeInterval...
ios -> onTimeInterval...
flutter: _AudioAppState.setPositionHandler => p 0:00:00.000000
player status: 1
ios -> updateDuration...28.682449
ios -> invokechannel
flutter: _AudioAppState.setPositionHandler => p 0:00:00.000000
flutter: _AudioAppState.setPositionHandler => p 0:00:00.000000
flutter: _AudioAppState.setDurationHandler => d 0:00:28.682000
ios -> onTimeInterval...
ios -> onTimeInterval...
flutter: _AudioAppState.setPositionHandler => p 0:00:00.000000
flutter: _AudioAppState.setPositionHandler => p 0:00:00.000000
ios -> onTimeInterval...
flutter: _AudioAppState.setPositionHandler => p 0:00:00.201000
ios -> onTimeInterval...
flutter: _AudioAppState.setPositionHandler => p 0:00:00.401000
ios -> onTimeInterval...
flutter: _AudioAppState.setPositionHandler => p 0:00:00.601000
ios -> onTimeInterval...

AudioplayerPlugin.h not found

Hi, using the plugin in the Simulator or on my phone in debug mode works flawlessly. But when I implement it in my app and build it using the 'archive' command it complains about the missing header file. Any idea why?

The same happens also with the example project

screen shot 2018-07-26 at 6 06 27 pm

Not playing on LG 440

I am having troubles playing with the audio player on a LG440H: (Android 6.01, 16 GB SDCard)

this is the error I am getting. The same app works OK on a Nexus 7.

I/flutter (12152): soundfile path = /data/user/0/com.yourcompany.muze/app_flutter/sound/Schippers-hetoverhevelenvangewicht-toelichting.mp3
E/ExtMediaPlayer-JNI(12152): QCMediaPlayer could not be located....
D/MediaPlayer-JNI(12152): JNIMediaPlayerFactory: bIsQCMediaPlayerPresent 0
E/ExtMediaPlayer-JNI(12152): QCMediaPlayer could not be located....
D/MediaPlayer-JNI(12152): JNIMediaPlayerFactory: bIsQCMediaPlayerPresent 0
V/MediaPlayerNative: constructor
D/AudioSystem(12152): getIoDescriptor: ioHandle = 2, index = -2, mIoDescriptors = 0xb9cddd28
V/AudioSystem(12152): ioConfigChanged: [Update mIoDescriptors] add ioHandle = 2 -> descriptor = 0xa0be977c
V/AudioSystem(12152): ioConfigChanged() new output opened 2 samplingRate 48000, format 0x1 channel mask 0x3 frameCount 960 deviceId 2
D/AudioSystem(12152): getIoDescriptor: ioHandle = 4, index = -2, mIoDescriptors = 0xb9cddd28
V/AudioSystem(12152): ioConfigChanged: [Update mIoDescriptors] add ioHandle = 4 -> descriptor = 0xa0be977c
V/AudioSystem(12152): ioConfigChanged() new output opened 4 samplingRate 48000, format 0x5 channel mask 0x3 frameCount 960 deviceId 2
V/MediaPlayerNative: setListener
V/MediaPlayerNative: MediaPlayer::setAudioStreamType
V/MediaPlayerNative: setDataSource(61, 0, 576460752303423487)
E/MediaPlayerNative: Unable to create media player
W/System.err(12152): java.io.IOException: setDataSourceFD failed.: status=0x80000000
W/System.err(12152): at android.media.MediaPlayer._setDataSource(Native Method)
W/System.err(12152): at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1133)
W/System.err(12152): at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1118)
W/System.err(12152): at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1097)
W/System.err(12152): at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1046)
W/System.err(12152): at bz.rxla.audioplayer.AudioplayerPlugin.play(AudioplayerPlugin.java:85)
W/System.err(12152): at bz.rxla.audioplayer.AudioplayerPlugin.onMethodCall(AudioplayerPlugin.java:44)
W/System.err(12152): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:191)
W/System.err(12152): at io.flutter.view.FlutterView.handlePlatformMessage(FlutterView.java:690)
W/System.err(12152): at android.os.MessageQueue.nativePollOnce(Native Method)
W/System.err(12152): at android.os.MessageQueue.next(MessageQueue.java:323)
W/System.err(12152): at android.os.Looper.loop(Looper.java:135)
W/System.err(12152): at android.app.ActivityThread.main(ActivityThread.java:5527)
W/System.err(12152): at java.lang.reflect.Method.invoke(Native Method)
W/System.err(12152): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730)
W/System.err(12152): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
D/AUDIO (12152): invalid DataSource
V/MediaPlayerNative: setVideoSurfaceTexture
V/MediaPlayerNative: setVideoSurfaceTexture: 0x0 mPlayer: NO_INIT
V/MediaPlayerNative: prepare
E/MediaPlayerNative: prepareAsync called in state 1
E/MethodChannel#bz.rxla.flutter/audio(12152): Failed to handle method call
E/MethodChannel#bz.rxla.flutter/audio(12152): java.lang.IllegalStateException
E/MethodChannel#bz.rxla.flutter/audio(12152): at android.media.MediaPlayer._prepare(Native Method)
E/MethodChannel#bz.rxla.flutter/audio(12152): at android.media.MediaPlayer.prepare(MediaPlayer.java:1163)
E/MethodChannel#bz.rxla.flutter/audio(12152): at bz.rxla.audioplayer.AudioplayerPlugin.play(AudioplayerPlugin.java:92)
E/MethodChannel#bz.rxla.flutter/audio(12152): at bz.rxla.audioplayer.AudioplayerPlugin.onMethodCall(AudioplayerPlugin.java:44)
E/MethodChannel#bz.rxla.flutter/audio(12152): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:191)
E/MethodChannel#bz.rxla.flutter/audio(12152): at io.flutter.view.FlutterView.handlePlatformMessage(FlutterView.java:690)
E/MethodChannel#bz.rxla.flutter/audio(12152): at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#bz.rxla.flutter/audio(12152): at android.os.MessageQueue.next(MessageQueue.java:323)
E/MethodChannel#bz.rxla.flutter/audio(12152): at android.os.Looper.loop(Looper.java:135)
E/MethodChannel#bz.rxla.flutter/audio(12152): at android.app.ActivityThread.main(ActivityThread.java:5527)
E/MethodChannel#bz.rxla.flutter/audio(12152): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#bz.rxla.flutter/audio(12152): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730)
E/MethodChannel#bz.rxla.flutter/audio(12152): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
E/flutter (12152): [ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] Unhandled exception:
E/flutter (12152): PlatformException(error, null, null)
E/flutter (12152): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:514)
E/flutter (12152): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:154)
E/flutter (12152):
E/flutter (12152): #2 AudioPlayer.play (package:audioplayer/audioplayer.dart:27)
E/flutter (12152): #3 _MuzeAudioPlayerState._playLocal (file:///Users/johan/projecten/muze/Code/flutter/muze/lib/muzeutils.dart:358)
E/flutter (12152):
E/flutter (12152): #4 _MuzeAudioPlayerState.build. (file:///Users/johan/projecten/muze/Code/flutter/muze/lib/muzeutils.dart:436)
E/flutter (12152): #5 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:323)
E/flutter (12152): #6 _InkResponseState.build. (package:flutter/src/material/ink_well.dart:375)
E/flutter (12152): #7 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:102)
E/flutter (12152): #8 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:149)
E/flutter (12152): #9 TapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:92)
E/flutter (12152): #10 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:315)
E/flutter (12152): #11 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:73)
E/flutter (12152): #12 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:101)
E/flutter (12152): #13 BindingBase&SchedulerBinding&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:143)
E/flutter (12152): #14 BindingBase&SchedulerBinding&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:121)
E/flutter (12152): #15 BindingBase&SchedulerBinding&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:101)
E/flutter (12152): #16 BindingBase&SchedulerBinding&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:64)
E/flutter (12152): #17 BindingBase&SchedulerBinding&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:48)
E/flutter (12152): #18 _invoke1 (file:///b/build/slave/Linux_Engine/build/src/flutter/lib/ui/hooks.dart:105)
E/flutter (12152): #19 _dispatchPointerDataPacket (file:///b/build/slave/Linux_Engine/build/src/flutter/lib/ui/hooks.dart:63)

After I try to load another sound ( by going to another page and reloading the sound), this is the message I am getting:

E/MediaPlayerNative: Attempt to call getDuration without a valid mediaplayer
V/MediaPlayerNative: message received msg=100, ext1=-38, ext2=0
E/MediaPlayerNative: error (-38, 0)
V/MediaPlayerNative: signal application thread
V/MediaPlayerNative: start
E/MediaPlayerNative: start called in state 0
V/MediaPlayerNative: message received msg=100, ext1=-38, ext2=0
V/MediaPlayerNative: notify(100, -38, 0) callback on disconnected mediaplayer
I/flutter (12152): _platformCallHandler call audio.onDuration 1893238280
V/MediaPlayerNative: message received msg=100, ext1=-38, ext2=0
V/MediaPlayerNative: notify(100, -38, 0) callback on disconnected mediaplayer
V/MediaPlayerNative: isPlaying: no active player
I/flutter (12152): nessage in HomePage is playing
V/MediaPlayerNative: isPlaying: no active player
V/MediaPlayerNative: message received msg=100, ext1=-38, ext2=0
V/MediaPlayerNative: notify(100, -38, 0) callback on disconnected mediaplayer
I/flutter (12152): nessage is playing
I/flutter (12152): nessage is playing
I/flutter (12152): nessage in HomePage is playing
I/flutter (12152): nessage is playing
I/flutter (12152): nessage in HomePage is playing
I/flutter (12152): nessage is playing
I/flutter (12152): _platformCallHandler call audio.onCurrentPosition 1893238240
V/MediaPlayerNative: isPlaying: no active player
V/MediaPlayerNative: message received msg=100, ext1=-38, ext2=0

Make AudioPlayer._state public

Could you make this public so we can read the current state instead of having us manage it manually? I don't see why these 2 shouldn't be tied together since we shouldn't need to play audio and say that it's paused. I'm having an issue where I've told it to play, I switch tabs and come back and it's still playing, but my own state variable shows paused because the variable got reset. I'm working on a way to get around that, but I think it would be much less work if the state variable was accessible from outside the class.

Allow to play multiple sounds simultaneoustly

I got everything working properly. What I am trying to do is play some sounds followed by another, without interupting the previous one. If I do something like this:

for (int i = 0; i < 5; i++) {
      int soundIndex = random.nextInt(5) + 1;
      play(soundIndex);
 }

then obviously it gets messed up and they overwrite each other. How can I achieve this effect?

How to use seek method

I want to implement return to previous listening position but each time I'm calling seek(25.0) Flutter app is crashing. Is there a specific way to call this method ? Thank you.

Audio Player depends on Activity during plugin registration

Hi,

In our app, we're trying to support registering plugins before the Android Activity has started in order to allow the Dart code to execute in the background. This requires plugins not to access the Activity during their registration method.

It seems like you don't need reference to the Activity. I will send a pull request. Please let me know if you have any questions about what we're trying to do.

--Alan

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.