Show / Hide Table of Contents

Class PlaySoundAction

An action that will play a sound to completion.

Inheritance
System.Object
DependencyObject
TriggerAction
TriggerAction<DependencyObject>
PlaySoundAction
Implements
IAttachedObject
Inherited Members
TriggerAction<DependencyObject>.AssociatedObject
TriggerAction<DependencyObject>.AssociatedObjectTypeConstraint
TriggerAction.IsEnabledProperty
TriggerAction.IsEnabled
TriggerAction.OnAttached()
TriggerAction.OnDetaching()
TriggerAction.IAttachedObject.AssociatedObject
TriggerAction.Attach(DependencyObject)
TriggerAction.Detach()
DependencyObject.GetValue(DependencyProperty)
DependencyObject.SetCurrentValue(DependencyProperty, Object)
DependencyObject.ReadLocalValue(DependencyProperty)
DependencyObject.SetValue(DependencyProperty, Object)
DependencyObject.SetValue(DependencyPropertyKey, Object)
DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs)
DependencyObject.CoerceValue(DependencyProperty)
DependencyObject.Dispatcher
DependencyObject.INTERNAL_OnAttachedToVisualTree()
DependencyObject.INTERNAL_OnDetachedFromVisualTree()
DependencyObject.ClearValue(DependencyProperty)
DependencyObject.ClearValue(DependencyPropertyKey)
DependencyObject.CheckAccess()
DependencyObject.GetAnimationBaseValue(DependencyProperty)
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Microsoft.Expression.Interactivity.Media
Assembly: OpenSilver.Expression.Interactions.dll
Syntax
public class PlaySoundAction : TriggerAction<DependencyObject>, IDependencyObject, 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 Source

PlaySoundAction()

Initializes a new instance of the PlaySoundAction class.

Declaration
public PlaySoundAction()

Fields

| Improve this Doc View Source

SourceProperty

Declaration
public static readonly DependencyProperty SourceProperty
Field Value
Type Description
DependencyProperty
| Improve this Doc View Source

VolumeProperty

Declaration
public static readonly DependencyProperty VolumeProperty
Field Value
Type Description
DependencyProperty

Properties

| Improve this Doc View Source

Source

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.

| Improve this Doc View Source

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 Source

Invoke(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
TriggerAction.Invoke(Object)
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.

| Improve this Doc View Source

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.

Implements

IAttachedObject

Extension Methods

DependencyObjectHelper.GetSelfAndAncestors(DependencyObject)
  • Improve this Doc
  • View Source