Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter audioplayers error (1, -19) - No audio is played and the app doesn't crash

Tags:

flutter

I am trying to use the flutter audioplayers package to play audio files and am getting this error. While following an online flutter tutorial I had this exact code and it ran and produced sound correctly, but now it doesn't play audio. I think maybe there is a change in my IDE settings or a change on my computer, but I don't know how to find the issue.

E/MediaPlayerNative(13949): error (1, -19)
E/MediaPlayer(13949): Error (1,-19)
E/MediaPlayerNative(13949): stop called in state 0, mPlayer(0xb4e843c0)
E/MediaPlayerNative(13949): error (-38, 0)
V/MediaPlayer(13949): resetDrmState:  mDrmInfo=null mDrmProvisioningThread=null mPrepareDrmInProgress=false mActiveDrmScheme=false
V/MediaPlayer(13949): cleanDrmObj: mDrmObj=null mDrmSessionId=null
V/MediaPlayer(13949): resetDrmState:  mDrmInfo=null mDrmProvisioningThread=null mPrepareDrmInProgress=false mActiveDrmScheme=false
V/MediaPlayer(13949): cleanDrmObj: mDrmObj=null mDrmSessionId=null

Here is the code I'm using to test the audioplayers package.

import 'package:flutter/material.dart';
import 'package:audioplayers/audio_cache.dart';

void main() => runApp(XylophoneApp());

class XylophoneApp extends StatelessWidget {
  final player = AudioCache();

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: SafeArea(
          child: Center(
            child: FlatButton(
              color: Colors.red,
              onPressed: () {
                player.play('note1.wav');
              },
              child: Text('Click Me'),
            ),
          ),
        ),
      ),
    );
  }
}
like image 840
Grayson Harrington Avatar asked Aug 16 '20 03:08

Grayson Harrington


1 Answers

i faced the same issue , and no solution works for me , until i changed the package , check this one , it's very nice and works without any problem . assets_audio

    playQRScannerSound() async {
    AssetsAudioPlayer.newPlayer().open(
      Audio("assets/audios/scan_Beep.mp3"),
      autoStart: true,
    );
  }

I hope it help you , best of luck .

like image 52
Peter aziz Avatar answered Oct 21 '22 06:10

Peter aziz