PrepAway - Latest Free Exam Questions & Answers

What should you do?

You use Microsoft .NET Framework 4 to create a Windows Presentation Foundation (WPF) application.
You want to add an audio player that plays .wav or .mp3 files when the user clicks a button.
You plan to store the name of the file to a variable named SoundFilePath.
You need to ensure that when a user clicks the button, the file provided by SoundFilePath plays.
What should you do?

PrepAway - Latest Free Exam Questions & Answers

A.
Write the following code segment in the button onclick event.
System.Media.SoundPlayer player = new System.Media.
SoundPlayer(SoundFilePath); player.play();

B.
Write the following code segment in the button onclick event.
MediaPlayer player = new MediaPlayer();
player.Open(new URI(SoundFilePath), UriKind.Relative)); player.play();

C.
Use the following code segment from the PlaySound() Win32 API function and call the PlaySound function in the button onclick event.
[sysimport(dll=”winmm.dll”)]
public static extern long PlaySound(String SoundFilePath, long hModule, long dwFlags);

D.
Reference the Microsoft.DirectX Dynamic Link Libraries. Use the following code segment in the button onclick event.
Audio song = new Song(SoundFilePath);
song.CurrentPosition = song.Duration; song.Play();


Leave a Reply