audioplayers icon indicating copy to clipboard operation
audioplayers copied to clipboard

bug(ios): AVPlayerItemStatus.failed when play url without file extension

Open kuntadynithesh opened this issue 3 years ago • 7 comments

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
            },
          ),
        )),
      ),
    );
  }
}

kuntadynithesh avatar Mar 18 '21 08:03 kuntadynithesh

@luanpotter Any update on this ?

kuntadynithesh avatar Apr 19 '21 16:04 kuntadynithesh

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.

tamoyal avatar May 05 '21 23:05 tamoyal

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 avatar May 05 '21 23:05 tamoyal

@tamoyal My file has .mpga extension and yet it is not playing . Ay reasons you guess ?

kuntadynithesh avatar May 11 '21 18:05 kuntadynithesh

@kuntadynithesh Convert to mp3 and try it? Then you'll know

tamoyal avatar May 11 '21 20:05 tamoyal

find the same issue. please fix it.

curls avatar Nov 21 '22 08:11 curls

We need a way to provide the mime Type to the player: https://stackoverflow.com/a/54087143/5164462

Gustl22 avatar Sep 27 '23 20:09 Gustl22