Visual Basic (Declaration) | |
---|---|
<LicenseProviderAttribute(System.ComponentModel.LicenseProvider)> Public Class LiveSound Inherits System.Web.UI.Control Implements ILiveControl |
Visual Basic (Usage) | Copy Code |
---|---|
Dim instance As LiveSound |
C# | |
---|---|
[LicenseProviderAttribute(System.ComponentModel.LicenseProvider)] public class LiveSound : System.Web.UI.Control, ILiveControl |
C++/CLI | |
---|---|
[LicenseProviderAttribute(System.ComponentModel.LicenseProvider)] public ref class LiveSound : public System.Web.UI.Control, ILiveControl |
The following example demonstrates adding items to a Live List control from a database, as well as updating a LiveImage control.
Visual Basic | 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 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(); } } |
Use LiveSound.Play to play a sound file located at LiveSound.Source.
NOTE! Only Internet Explorer has the capability of playing sounds from a callback by default. Other browser types (Mozilla, Opera, etc) use a Flash movie to play the sound from a callback. For these browsers, the played sound must be MP3 format.
System.Object
System.Web.UI.Control
Dart.LiveControls.LiveSound
Target Platforms: Microsoft .NET Framework 2.0