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
750 stars 352 forks source link

Flutter web interacts with the audio element #307

Open DomingoMG opened 4 years ago

DomingoMG commented 4 years ago

I am creating a web application with this repository, my question is if it is possible to access the HTML5 player through an id to use WEBRTC to change the audio output of the card.

If so, where should I configure the player id to use eg AudioElement audio = AudioElement (src);

example https://webrtc.github.io/samples/src/content/devices/multi/

florent37 commented 4 years ago

I don't know sorry :/ I'll need some help for this

DomingoMG commented 4 years ago

Does this repository play HTML5 audio when running on web flapping?

if it is HTML5 audio, is it possible to assign an id or class to the player? I just need to define to connect to webrtc.

class

<audio class="player1" controls="controls" preload="auto" >
                  <source src="audio.mp3" type="audio/mpeg" />
                  <source src="audio.ogg" type="audio/ogg" />
               </audio>

id

<audio id="player2" controls="controls" preload="auto" >
                  <source src="audio.mp3" type="audio/mpeg" />
                  <source src="audio.ogg" type="audio/ogg" />
               </audio>

Being an audio, the element it returns is AudioElement audio = querySelector ("#player2 or .player1");

With the audio attribute I can interact with dart.

I think it would be like this by adding two methods in this file. web_player_html.dart

set assignIdToPlayer( String idName ){
    _audioElement.id = idName;
    channel.invokeMethod(method...., idName);
  }

  set assignClassToPlayer( String className ){
    _audioElement.className = className;
    channel.invokeMethod(method..., className);
  }

Read more https://api.dart.dev/stable/2.8.4/dart-html/querySelector.html

Sorry for the inconvenience and thanks for your attention.