Class PlaySoundAction
An action that will play a sound to completion.
Inheritance
Implements
Inherited Members
Namespace: Microsoft.Expression.Interactivity.Media
Assembly: OpenSilver.Expression.Interactions.dll
Syntax
public class PlaySoundAction : TriggerAction<DependencyObject>, IAttachedObject
Remarks
This action is intended for use with short sound effects that don't need to be stopped or controlled. If you're trying to create a music player or game, it may not meet your needs.
Constructors
| Improve this Doc View SourcePlaySoundAction()
Initializes a new instance of the PlaySoundAction class.
Declaration
public PlaySoundAction()
Fields
| Improve this Doc View SourceSourceProperty
Declaration
public static readonly DependencyProperty SourceProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
VolumeProperty
Declaration
public static readonly DependencyProperty VolumeProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
Properties
| Improve this Doc View SourceSource
A Uri defining the location of the sound file. This is used to set the source property of the MediaElement. This is a dependency property.
Declaration
public Uri Source { get; set; }
Property Value
Type | Description |
---|---|
System.Uri |
Remarks
The sound can be any file format supported by MediaElement. In the case of a video, it will play only the audio portion.
Volume
Control the volume of the sound. This is used to set the Volume property of the MediaElement. This is a dependency property.
Declaration
public double Volume { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
Methods
| Improve this Doc View SourceInvoke(Object)
This method is called when some criteria are met and the action should be invoked.
Declaration
protected override void Invoke(object parameter)
Parameters
Type | Name | Description |
---|---|---|
System.Object | parameter |
Overrides
Remarks
Each invocation of the Action plays a new sound. Although the implementation is subject-to-change, the caller should anticipate that this will create a new MediaElement that will be cleaned up when the sound completes or if the media fails to play.
SetMediaElementProperties(MediaElement)
When the action is invoked, this method is used to customize the dynamically created MediaElement.
Declaration
protected virtual void SetMediaElementProperties(MediaElement mediaElement)
Parameters
Type | Name | Description |
---|---|---|
MediaElement | mediaElement |
Remarks
This method may be useful for Action authors who wish to extend PlaySoundAction. If you want to control the MediaElement Balance property, you could inherit from PlaySoundAction and override this method.