Add and Manage Content

  BackBy —

These questions are based on 70-502 CSHP - TS - Microsoft .NET Framework 3.5: Windows Presentation Foundation (C# .NET)
Microsoft
Self Test Software Practice Test

Objective: Add and manage content.
Sub-objective: Add multimedia content.

Single answer, multiple-choice

You are developing a Windows Presentation Foundation (WPF) application using the Microsoft .NET 3.5 Framework. You have two sound files that are associated with each other. You want to play both sound files simultaneously. You want to achieve this with best optimization.

What should you do to play two sound files simultaneously?

  1. Add the following markup in the XAML file:
    <MediaElement Name="me" />

    Add the following code in the code-behind file:
    me.Source="sound1.wav";
    me.Source="sound2.wav";
  2. Add the following markup in the XAML file:
    <MediaElement Name="me1" />
    <MediaElement Name="me2" />

    Add the following code in the code-behind file:
    me1.Source="sound1.wav";
    me2.Source="sound2.wav";
  3. Add the following markup in the XAML file:
    <MediaPlayer Name="mp" />

    Add the following code in the code-behind file:
    mp.Source="sound1.wav";
    mp.Source="sound2.wav";
  4. Add the following markup in the XAML file:
    <MediaElement Name="mp1" />
    <MediaElement Name="mp2" />

    Add the following code in the code-behind file:
    mp1.Source="sound1.wav";
    mp2.Source="sound2.wav";

Answer:
D. Add the following markup in the XAML file:
    <MediaElement Name="mp1" />
    <MediaElement Name="mp2" />

    Add the following code in the code-behind file:
    mp1.Source="sound1.wav";
    mp2.Source="sound2.wav";

Tutorial:
You should create separate MediaPlayer objects for each sound file to run both sound files simultaneously and optimize their performance. MediaPlayer is used to add media files on the application. MediaPlayer cannot load or play media without using code. Through code you should create two separate objects of the MediaPlayer class and specify the Source property for each object. Therefore, the markup should be as follows:

<MediaElement Name="mp1" />
<MediaElement Name="mp2" />

The code-behind file code should be as follows:

mp1.Source="sound1.wav";
mp2.Source="sound2.wav";

You should not use the same MediaElement for both sound files with different sources. By using the same media element for both sound files, the first file will overlap the first sound file. Therefore, there should be a separate element for each sound file. To optimize performance, you should use MediaPlayer instead of MediaElement because MediaElement takes more resources.

You should not create separate MediaElement elements for each sound file because MediaElement takes more resources. To optimize performance, you should use MediaPlayer instead of MediaElement.

You should not use the same MediaPlayer object for both sound files with different sources. By using the same media object for both sound files, the second file will overlap the first sound file. Therefore, there should be separate objects for both sound files.

Reference:
MSDN2 > MSDN Library > .Net Development > .Net Framework 3.5 > .Net Framework > Windows Presentation Foundation > Graphics and Multimedia > Multimedia > Multimedia Overview

MSDN2 > MSDN Library > .Net Development > .Net Framework 3.5 > .Net Framework > .Net Framework Class Library > System.Windows.Media Namespace > MediaPlayer Class

MSDN2 > MSDN Library > .Net Development > .Net Framework 3.5 > .Net Framework > .Net Framework Class Library > System.Windows.Media Namespace > MediaElement Class

Viewed 6395 times.
SPONSORED LINKS