Flutter-AssetsAudioPlayer icon indicating copy to clipboard operation
Flutter-AssetsAudioPlayer copied to clipboard

App crashes when it regains audio focus while in the background on android 14

Open hmukwana opened this issue 1 year ago • 2 comments

Flutter Version

My version : 3.24

Lib Version

My version : 3.0.0

Platform (Android / iOS / web) + version

Platform : Android 14

Describe the bug

App crashes when it tries to resume playback after regaining audio focus while still in the background.

Small code to reproduce

import 'package:assets_audio_player/assets_audio_player.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State {
  
  final AssetsAudioPlayer _assetsAudioPlayer = AssetsAudioPlayer();

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: RaisedButton(
            child: Text("open"),
            onPressed: () {
              Audio audio = Audio.network(
        newSermon.mediaLink ?? '',
        metas: Metas(
          id: id.toString(),
          title: title,
          album: albumName,
          image: artLink,
        ),
      );

    audioPlayer.open(
      audio,
      showNotification: true,
      notificationSettings: NotificationSettings(
    );
            }
          ),
        ),
      ),
    );
  }
}

hmukwana avatar Sep 08 '24 17:09 hmukwana