0

I am just trying to add audioplayers pub to my application. but it is going for error, like:

resetDrmState:  mDrmInfo=null mDrmProvisioningThread=null mPrepareDrmInProgress=false mActiveDrmScheme=false

I tried all issues published in Stackoverflow. But I could not get the point.

This is my code:

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

final player = AudioPlayer();

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text("data"),
        ),
        body: Center(
          child: TextButton(
            onPressed: () {
              player.setSource(AssetSource("sound/n1.wav"));
            },
            child: Text("data"),
          ),
        ),
      ),
    );
  }
}

What are the resources I tried:

- Flutter audioplayers error - No audio is played when clicking the audio button

- Android Studio resetDrmState message on MediaPlayer release and set to null

1 Answers1

0

This helped for me:

final player = AudioPlayer();

final bundle = await rootBundle.load("sound/n1.wav");

final bytes = bytes.buffer.asUint8List(bundle.offsetInBytes, bundle.lengthInBytes);

final status = await player.playBytes(audiobytes);

if (status == 1) {
 // playing
}
BalgabayevD
  • 44
  • 1
  • 4
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 22 '23 at 03:26