florent37 / Flutter-AssetsAudioPlayer

Play simultaneously music/audio from assets/network/file directly from Flutter, compatible with android / ios / web / macos, displays notifications
https://pub.dartlang.org/packages/assets_audio_player
Apache License 2.0
740 stars 337 forks source link

Network Asset doesnt work. #488

Closed leossmith closed 3 years ago

leossmith commented 3 years ago

Flutter Version

My version : Flutter 2

Lib Version

My version : 2.0.14

Platform (Android / iOS / web) + version

Platform : Android 11

Describe the bug

I am trying to play a .mp3 and a .aac file from my firebase storage. When I hit play nothing happens. I tried a different package and it works as should.

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 {
final assetsAudioPlayer = AssetsAudioPlayer();
  var MY_LIVESTREAM_URL = 'MYMP3';

 bool playing = false;

  void playMusic() async {
    print('play');
      try {
        await assetsAudioPlayer.open(
          Audio.network(MY_LIVESTREAM_URL,),
        );

        playing = true;
      } catch (t) {
        print('unreachable music');
      }

    if (!playing) {
      setState(() {
        assetsAudioPlayer.play();
        //playPayseBtn = 'assets/pauseBtn.png';
        playing = true;
      });
    } else {
      setState(() {
        playing = false;
        assetsAudioPlayer.pause();
        //playPayseBtn = 'assets/playBtn.png';
      });
    }
  }
  @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: () {
              playMusic()
            }
          ),
        ),
      ),
    );
  }
}

Log:

I/TetheringManager(17619): registerTetheringEventCallback:tech.simpleapps.perasmata
W/eapps.perasmat(17619): Accessing hidden method Landroid/media/AudioTrack;->getLatency()I (greylist, reflection, allowed)
I/ExoPlayerImpl(17619): Init 4afbba6 [ExoPlayerLib/2.13.0] [generic_x86_arm, sdk_gphone_x86, Google, 30]
I/VideoCapabilities(17619): Unsupported profile 4 for video/mp4v-es
D/CCodec  (17619): allocate(c2.android.mp3.decoder)
I/Codec2Client(17619): Available Codec2 services: "software"
I/CCodec  (17619): Created component [c2.android.mp3.decoder]
D/CCodecConfig(17619): read media type: audio/mpeg
D/ReflectedParamUpdater(17619): extent() != 1 for single value type: algo.buffers.max-count.values
D/ReflectedParamUpdater(17619): extent() != 1 for single value type: output.subscribed-indices.values
D/ReflectedParamUpdater(17619): extent() != 1 for single value type: input.buffers.allocator-ids.values
D/ReflectedParamUpdater(17619): extent() != 1 for single value type: output.buffers.allocator-ids.values
D/ReflectedParamUpdater(17619): extent() != 1 for single value type: algo.buffers.allocator-ids.values
D/ReflectedParamUpdater(17619): extent() != 1 for single value type: output.buffers.pool-ids.values
D/ReflectedParamUpdater(17619): extent() != 1 for single value type: algo.buffers.pool-ids.values
I/CCodecConfig(17619): query failed after returning 7 values (BAD_INDEX)
D/CCodecConfig(17619): c2 config diff is Dict {
D/CCodecConfig(17619):   c2::u32 coded.bitrate.value = 64000
D/CCodecConfig(17619):   c2::u32 input.buffers.max-size.value = 8192
D/CCodecConfig(17619):   c2::u32 input.delay.value = 0
D/CCodecConfig(17619):   string input.media-type.value = "audio/mpeg"
D/CCodecConfig(17619):   string output.media-type.value = "audio/raw"
D/CCodecConfig(17619):   c2::u32 raw.channel-count.value = 2
D/CCodecConfig(17619):   c2::u32 raw.sample-rate.value = 44100
D/CCodecConfig(17619): }
D/CCodec  (17619): [c2.android.mp3.decoder] buffers are bound to CCodec for this session
D/CCodecConfig(17619): no c2 equivalents for flags
D/CCodecConfig(17619): config failed => CORRUPTED
D/CCodecConfig(17619): c2 config diff is   c2::u32 raw.channel-count.value = 1
D/CCodecConfig(17619):   c2::u32 raw.sample-rate.value = 48000
W/Codec2Client(17619): query -- param skipped: index = 1107298332.
D/CCodec  (17619): client requested max input size 4096, which is smaller than what component recommended (8192); overriding with component recommendation.
W/CCodec  (17619): This behavior is subject to change. It is recommended that app developers double check whether the requested max input size is in reasonable range.
D/CCodec  (17619): setup formats input: AMessage(what = 0x00000000) = {
D/CCodec  (17619):   int32_t channel-count = 1
D/CCodec  (17619):   int32_t max-input-size = 8192
D/CCodec  (17619):   string mime = "audio/mpeg"
D/CCodec  (17619):   int32_t sample-rate = 48000
D/CCodec  (17619): } and output: AMessage(what = 0x00000000) = {
D/CCodec  (17619):   int32_t channel-count = 1
D/CCodec  (17619):   string mime = "audio/raw"
D/CCodec  (17619):   int32_t sample-rate = 48000
D/CCodec  (17619): }
W/Codec2Client(17619): query -- param skipped: index = 1342179345.
W/Codec2Client(17619): query -- param skipped: index = 2415921170.
E/FMQ     (17619): grantorIdx must be less than 3
E/FMQ     (17619): grantorIdx must be less than 3
D/CCodecBufferChannel(17619): [c2.android.mp3.decoder#46] Created input block pool with allocatorID 16 => poolID 17 - OK (0)
I/CCodecBufferChannel(17619): [c2.android.mp3.decoder#46] Created output block pool with allocatorID 16 => poolID 32 - OK
D/CCodecBufferChannel(17619): [c2.android.mp3.decoder#46] Configured output block pool ids 32 => OK
E/ion     (17619): ioctl c0044901 failed with code -1: Inappropriate ioctl for device
E/FMQ     (17619): grantorIdx must be less than 3
E/FMQ     (17619): grantorIdx must be less than 3
D/AudioTrack(17619): getTimestamp_l(22): device stall time corrected using current time 35675589807800
D/BufferPoolAccessor2.0(17619): bufferpool2 0xe7489818 : 5(40960 size) total buffers - 4(32768 size) used buffers - 0/5 (recycle/alloc) - 4/36 (fetch/transfer)
D/BufferPoolAccessor2.0(17619): evictor expired: 1, evicted: 1
kalismeras61 commented 3 years ago

Please check Readme.md file. image: MetasImage.network( //my new image url ),