Dart DocumentationstagexlAudioElementSoundChannel

AudioElementSoundChannel class

class AudioElementSoundChannel extends SoundChannel {

 AudioElementSound _audioElementSound;
 AudioElement _audio;

 bool _loop;
 SoundTransform _soundTransform;

 AudioElementSoundChannel(AudioElementSound audioElementSound, bool loop, SoundTransform soundTransform) {

   _audioElementSound = audioElementSound;
   _soundTransform = (soundTransform != null) ? soundTransform : new SoundTransform();
   _loop = loop;

   _audio = audioElementSound._getAudioElement(this);
   SoundMixer._audioElementMixer._updateSoundChannel(this);

   _audio.loop = _loop;
   _audio.play();
 }

 //-------------------------------------------------------------------------------------------------
 //-------------------------------------------------------------------------------------------------

 SoundTransform get soundTransform => _soundTransform;

 void set soundTransform(SoundTransform value) {

   _soundTransform = (value != null) ? value : new SoundTransform();
   SoundMixer._audioElementMixer._updateSoundChannel(this);
 }

 //-------------------------------------------------------------------------------------------------

 void stop() {

   if (_audio != null) {
     if (_audio.ended == false) _audio.pause();
     _audioElementSound._releaseAudioElement(this);
     _audio = null;
   }
 }

}

Extends

EventDispatcher > SoundChannel > AudioElementSoundChannel

Constructors

new AudioElementSoundChannel(AudioElementSound audioElementSound, bool loop, SoundTransform soundTransform) #

Creates a new Object instance.

Object instances have no meaningful state, and are only useful through their identity. An Object instance is equal to itself only.

docs inherited from Object
AudioElementSoundChannel(AudioElementSound audioElementSound, bool loop, SoundTransform soundTransform) {

 _audioElementSound = audioElementSound;
 _soundTransform = (soundTransform != null) ? soundTransform : new SoundTransform();
 _loop = loop;

 _audio = audioElementSound._getAudioElement(this);
 SoundMixer._audioElementMixer._updateSoundChannel(this);

 _audio.loop = _loop;
 _audio.play();
}

Properties

SoundTransform soundTransform #

SoundTransform get soundTransform => _soundTransform;
void set soundTransform(SoundTransform value) {

 _soundTransform = (value != null) ? value : new SoundTransform();
 SoundMixer._audioElementMixer._updateSoundChannel(this);
}

Methods

StreamSubscription<Event> addEventListener(String eventType, EventListener eventListener, {bool useCapture: false, int priority: 0}) #

inherited from EventDispatcher
StreamSubscription<Event> addEventListener(String eventType, EventListener eventListener, {
 bool useCapture: false, int priority: 0 }) {

 return this.on(eventType)._subscribe(eventListener, useCapture, priority);
}

void dispatchEvent(Event event) #

inherited from EventDispatcher
void dispatchEvent(Event event) {
 _dispatchEventInternal(event, this, EventPhase.AT_TARGET);
}

bool hasEventListener(String eventType) #

inherited from EventDispatcher
bool hasEventListener(String eventType) {

 var eventStreams = _eventStreams;
 if (eventStreams == null) return false;
 var eventStream = eventStreams[eventType];
 if (eventStream == null) return false;

 return eventStream.hasSubscriptions;
}

EventStream<Event> on(String eventType) #

inherited from EventDispatcher
EventStream<Event> on(String eventType) {

 var eventStreams = _eventStreams;
 if (eventStreams == null) {
   eventStreams = new Map<String, EventStream>();
   _eventStreams = eventStreams;
 }

 var eventStream = eventStreams[eventType];
 if (eventStream == null) {
   eventStream = new EventStream._internal(this, eventType);
   eventStreams[eventType] = eventStream;
 }

 return eventStream;
}

void removeEventListener(String eventType, EventListener eventListener, {bool useCapture: false}) #

inherited from EventDispatcher
void removeEventListener(String eventType, EventListener eventListener, {
 bool useCapture: false }) {

 this.on(eventType)._unsubscribe(eventListener, useCapture);
}

void removeEventListeners(String eventType) #

inherited from EventDispatcher
void removeEventListeners(String eventType) {
 this.on(eventType).cancelSubscriptions();
}

void stop() #

void stop() {

 if (_audio != null) {
   if (_audio.ended == false) _audio.pause();
   _audioElementSound._releaseAudioElement(this);
   _audio = null;
 }
}