0

What is the right way to call play on an audio element in AngularDart?
I know that I can use @ViewChild('audio') annotation to get ElementRef, but ElementRef is deprecated.

<div class="audio-controls">
    <material-fab raised (trigger)="onPlay()">
        <material-icon icon="play_arrow" ></material-icon>
    </material-fab>
</div>

<audio><source src="audio.ogg"></audio>
class AudioComponent {

  void onPlay() {
    //??
  }
}

1 Answer 1

1

I just started learning AngualDart. I see now that this is wrong approach. I should use AudioContext to play audio or eventually, as a last resort, create AudioElement inside AudioComponent. AudioElement doesn't have to be added to a DOM tree (?).

Template should be used to define interface not logic (audio tag).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.