PowerWEB LiveControls for ASP.NET
Play Method
See Also  Example Send comments on this topic.
Dart.LiveControls Namespace > LiveSound Class : Play Method



Plays a sound file.

Syntax

Visual Basic (Declaration) 
Public Sub Play() 
Visual Basic (Usage)Copy Code
Dim instance As LiveSound
 
instance.Play()
C# 
public void Play()
C++/CLI 
public:
void Play(); 

Example

The following example demonstrates adding items to a Live List control from a database, as well as updating a LiveImage control.
Visual BasicCopy Code
'In this example, items are added to a Live List using Items.Add
'The items are sounds to be played, located in a "sounds" folder
'When one of the items is selected, the corresponding sound is played
'LiveList1 could be a LiveListBox, LiveDropDownList, LiveRadioButtonList or LiveCheckBoxList

Private Sub LiveButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LiveButton1.Click
    'Add items to the Live list control via the ListItemCollection
    LiveList1.Items.Add("chord.wav")
    LiveList1.Items.Add("chimes.wav")
    LiveList1.Items.Add("exclamation.wav")
    LiveList1.Items.Add("error.wav")
End Sub

Private Sub LiveList1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LiveList1.SelectedIndexChanged
    'When an item in the LiveList is selected or de-selected
    'The selected sound that is topmost in the list will play
    If (LiveList1.SelectedIndex > -1) Then
        LiveSound1.Source = "sounds/" + LiveList1.Items(LiveList1.SelectedIndex).ToString()
        LiveSound1.Play()
    End If
End Sub
C#Copy Code
//In this example, items are added to a Live List using Items.Add
//The items are sounds to be played, located in a "sounds" folder
//When one of the items is selected, the corresponding sound is played
//LiveList1 could be a LiveListBox, LiveDropDownList, LiveRadioButtonList or LiveCheckBoxList

private void LiveButton1_Click(object sender, System.EventArgs e)
{
	//Add items to the Live List control via the ListItemCollection
	LiveList1.Items.Add("chord.wav");
	LiveList1.Items.Add("chimes.wav");
	LiveList1.Items.Add("exclamation.wav");
	LiveList1.Items.Add("error.wav");
}

private void LiveList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
	//When an item in the Live List is selected or de-selected
	//The selected sound that is topmost in the list will play
	if (LiveList1.SelectedIndex > -1)
	{
		LiveSound1.Source = "sounds/" + LiveList1.Items[LiveList1.SelectedIndex];
		LiveSound1.Play();
	}
}

Remarks

When used in a callback, plays the sound effect specified by LiveSound.Source. No effect when called in a postback.

Requirements

Target Platforms: Microsoft .NET Framework 2.0

See Also

Documentation Version 4.0.2
© 2012 Dart Communications. All Rights Reserved.