audioplayers
audioplayers copied to clipboard
bug(ios): AVPlayerItemStatus.failed when play url without file extension
AudioPlayer gives error when trying to play on device audio file on iOS : AVPlayerItemStatus.failed. Audio doesn't even start playing. On android it's working fine.
This is - #753 reopened . Ajay ( creator of #753) and myself work together on this .
I dont think its a issue with ios supported formats . Because AV foundation player built with swift code plays .mpga files perfectly . As @luanpotter has asked for a sample file . Here is the link for sample file https://drive.google.com/file/d/1UAmiVAaCi7B6OgVY-eWCd6s3Am4DK97e/view?usp=sharing
Code to reproduce :
import 'package:flutter/material.dart';
import 'dart:io' as io;
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
AudioPlayer _player = AudioPlayer();
final url =
'/Users/ajay/Library/Developer/CoreSimulator/Devices/C394D1D9-1355-46C4-9FED-B6F0728B963C/data/Containers/Data/Application/FAD80AED-2F99-4B46-9F71-02ADC2710FFF/Documents/xF58xz9cz43BgxmjVTyqlbuKUHN1dgbcRqwabg4p.mpga';
@override
void initState() {
super.initState();
AudioPlayer.logEnabled = true;
_player.onPlayerError.listen((msg) {
print('audioPlayer error : $msg');
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
backgroundColor: Colors.black12,
body: Center(
child: Container(
child: FlatButton(
child: Text('Play'),
color: Colors.greenAccent,
onPressed: () async {
_player.play(url, isLocal: true);
print(await io.File(url).exists()); // returns true
},
),
)),
),
);
}
}
@luanpotter Any update on this ?
Also getting this error and cannot get any audio file to play on iOS. As a quick test I have made sure playing the file works with other plugins.
Ok so the issue I found is that this plugin requires the file name have an extension or it errors. I think this should be somewhere in the docs. I'm kinda lucky I just guessed.
@tamoyal My file has .mpga extension and yet it is not playing . Ay reasons you guess ?
@kuntadynithesh Convert to mp3 and try it? Then you'll know
find the same issue. please fix it.
We need a way to provide the mime Type to the player: https://stackoverflow.com/a/54087143/5164462