Share via


SoundPlayer.SoundLocation 属性

定义

获取或设置要加载的 .wav 文件的文件路径或 URL。

public:
 property System::String ^ SoundLocation { System::String ^ get(); void set(System::String ^ value); };
public string SoundLocation { get; set; }
member this.SoundLocation : string with get, set
Public Property SoundLocation As String

属性值

从中加载 .wav 文件的文件路径或 URL,如果不存在文件路径,则为 Empty。 默认值为 Empty

示例

下面的代码示例演示如何使用 SoundLocation 属性将 .wav 文件源分配给 类的 SoundPlayer 实例。 此代码示例是为 SoundPlayer 类提供的一个更大示例的一部分。

try
{
   
   // Assign the selected file's path to 
   // the SoundPlayer object.  
   player->SoundLocation = filepathTextbox->Text;
   
   // Load the .wav file.
   player->Load();
}
catch ( Exception^ ex ) 
{
   ReportStatus( ex->Message );
}
try
{
    // Assign the selected file's path to 
    // the SoundPlayer object.  
    player.SoundLocation = filepathTextbox.Text;

    // Load the .wav file.
    player.Load();
}
catch (Exception ex)
{
    ReportStatus(ex.Message);
}
Try
    ' Assign the selected file's path to the SoundPlayer object.
    player.SoundLocation = filepathTextbox.Text

    ' Load the .wav file.
    player.Load()
Catch ex As Exception
    ReportStatus(ex.Message)
End Try

注解

当 属性设置为 String.Empty 时, Stream 此属性设置为 Stream

适用于

另请参阅