muslimtv / flutter_playout

AV Playout in Flutter
BSD 3-Clause "New" or "Revised" License
154 stars 93 forks source link

I/flutter ( 7268): onPlay() is Fired Twice #44

Open khashabawy opened 4 years ago

khashabawy commented 4 years ago

I/flutter ( 7268): onPlay() is Fired Twice, Can You tell the reason for that please ?

khashabawy commented 4 years ago

`I/flutter (10898): onPlay()

[log] play() > قصيدة الشاعر حافظ إبراهيم عن العربية

[log] PlayPause > play()

[log] isOnhold > false

I/flutter (10898): onPlay()

I/flutter (10898): onPlay()

[log] PlayPause > pause()

[log] isOnhold > true

I/flutter (10898): onPlay()

[log] pause()

I/flutter (10898): onPlay()

[log] play() > قصيدة الشاعر حافظ إبراهيم عن العربية

[log] PlayPause > play()

[log] isOnhold > false

I/flutter (10898): onPlay()

I/flutter (10898): onPlay()`

khashabawy commented 4 years ago

  Future<void> play({bool reset: true}) async {
    if(isPlaying == false && playerState != PlayerState.PLAYING) {
      if (streamData.file == null) {
        return;
      }

      if (isPlaying && reset == true) {
        await stop();
      }

      dev.log('play() > ' + streamData.title);

      try {
        await audioInstance.play(
          streamData.file,
          title: streamData.title,
          subtitle: streamData.subtitle,
          position: playbackPosition,
          isLiveStream: true,
        );

        setState(() {
          buffering = true;
        });
      } on PlatformException catch (e) {
        throw 'Unable to play ${streamData.title}: ${e.message}';
      }
    }
  }
khashabawy commented 4 years ago

If there is any chance to help me about this i would be grateful