question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

No listening changes in PlayStatus on Android

See original GitHub issue

Version of flutter_sound

2.1.1

flutter doctor

[✓] Flutter (Channel stable, v1.12.13+hotfix.8, on Mac OS X 10.15.3 19D76, locale pt-BR)
    • Flutter version 1.12.13+hotfix.8 at /Users/josuelopes/Downloads/flutter
    • Framework revision 0b8abb4724 (4 weeks ago), 2020-02-11 11:44:36 -0800
    • Engine revision e1e6ced81d
    • Dart version 2.7.0

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    • Android SDK at /Users/josuelopes/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.3.1, Build version 11C504
    • CocoaPods version 1.8.4

[✓] Android Studio (version 3.6)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 44.0.2
    • Dart plugin version 192.7761
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)

[✓] VS Code (version 1.42.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.8.1

[✓] Connected device (1 available)
    • Android SDK built for x86 • emulator-5554 • android-x86 • Android 10 (API 29) (emulator)

Platforms you faced the error (IOS or Android or both?)

Android

Expected behavior

Report the playback data to start a listener and observe the changes.

[Flutter Sound - Start Player] Player resumed
I/flutter (22476):  duration: 1, currentPosition: 0.203
I/flutter (22476):  duration: 1, currentPosition: 0.389
I/flutter (22476):  duration: 1, currentPosition: 0.541
I/flutter (22476):  duration: 1, currentPosition: 0.812
D/FlutterSoundPlugin(22476): Plays completed.

Actual behavior

On Android I am not receiving the data in the PlayStatus Stream listener, due to this I cannot verify the maximum and current audio time and whether it has finished.

[Flutter Sound - Start Player] Player resumed
D/FlutterSoundPlugin(22476): Plays completed.

Tested environment (Emulator? Real Device?)

Both (Emulator and Xiaomi Note 8)

Steps to reproduce the behavior

I’m using Flutter Sound in conjunction with Flutter Bloc.

The methods that correspond to the events are as follows:

  • First the download is performed:
  Stream<ChatState> _mapDownloadAudio(DownloadAudioChatEvent event) async* {
    Directory dir = await getTemporaryDirectory();
    String pathFile = '${dir.path}/${event.audio.fileName}.aac';
    String bucket =
        '${event.audio.path}/${detailsTalk.idTalk}/${event.audio.fileName}';
    File checkFile = File(pathFile);
    if (!await checkFile.exists()) {
      var response = await awsGet.getObject(bucket, pathFile);
      if (response.statusCode >= 200) {
        event.audio.file = File(pathFile);
        _updateAudioData(event.audio);
      }
    } else {
      event.audio.file = checkFile;
      _updateAudioData(event.audio);
    }
    yield DownloadedAudioChatState(conversations, event.audio);
  }
  • After the download, you can start the audio:
  Stream<ChatState> _mapEventPlayAudio(PlayAudioChatEvent event) async* {
    if (_sound != null && playerIsPlaying()) {
        await player.stopPlayer();
        _canceledPlayer(_sound);
        _updateAudioData(_sound);
        yield StopAudioChatState(conversations, _sound);
    }
    await _startPlayer(event.audio);
    _updateAudioData(event.audio);
    yield PlayAudioChatState(conversations, event.audio);
  }
  Future<void> _startPlayer(ExtraData audio) async {
    try {
      player.startPlayer(audio.file.path).then((message) {
        log(message, name: 'Flutter - Start Player');
        _onPlay = player.onPlayerStateChanged
            .listen((status) => listeningStatus(status));
      });
      audio.isPlaying = true;
      _sound = audio;
    } catch (e) {
      log(e.toString(), name: 'Flutter Sound - Error');
    }
  }
  void listeningStatus(PlayStatus status) {
    log(status.toString(), name: 'Player - PlayStatus');
    if (status != null) {
      _sound.timeStatus = status;
      add(UpdatePlayStatusChatEvent(_sound));
    } else {
      add(PauseAudioChatEvent(_sound));
    }
  }
bool playerIsPlaying() => player.audioState == t_AUDIO_STATE.IS_PLAYING;

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:14

github_iconTop GitHub Comments

1reaction
Larpouxcommented, Apr 13, 2020

@Josue10599 ,

Yes, I confirm that Flutter Sound and FCM are not good friends together. I tried to run the Flutter Sound Example with a special APP linked with Firebase Messaging, and it does not work. Android Media Player is really painful (I have many problems in Flutter Sound not correctly solved because of Android Media Player). I think it is time, now, to consider rewriting the Flutter Sound Recorder using other native tools. Just be patient … time is the bottle neck.

0reactions
Larpouxcommented, Dec 28, 2020

This duplicates [#212]

Read more comments on GitHub >

github_iconTop Results From Across the Web

No listening changes in PlayStatus on Android #235 - GitHub
On Android I am not receiving the data in the PlayStatus Stream listener, due to this I cannot verify the maximum and current...
Read more >
There is no sound when using a TV or audio system (such as ...
Disconnect the HDMI cable from the TV and audio system, and then reconnect it. On the TV, change the audio output destination setting...
Read more >
There is no sound from the TV while streaming or casting apps
Try the provided steps and test the app after completing each one: Check if the TV volume is set extremely low or muted....
Read more >
MLB.TV Help Center - Available Features
Listen to every regular season and Postseason game LIVE online and on supported Roku, Playstation, Xbox, Web, iOS and Android devices with no...
Read more >
How to use PS Remote Play on mobile devices - PlayStation
With Remote Play, you can control your PlayStation® console remotely ... If you're using an Android™ smartphone or tablet, button and icon designs...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found