我打算编写一个可以同时从HTTP流媒体服务器播放两个音频流的应用程序。在开始之前,我想确定Windows Phone设备和API是否支持此功能。
我想我必须使用两个MediaElement实例。有什么想法或建议吗?
编辑:我尝试使用以下代码,第一个停止,第二个播放,当我开始第二个播放时,第一个播放:
private void StopMedia1(object sender, RoutedEventArgs e)
{
media1.Stop();
}
private void PauseMedia1(object sender, RoutedEventArgs e)
{
media1.Pause();
}
private void PlayMedia1(object sender, RoutedEventArgs e)
{
media1.Play();
}
private void StopMedia2(object sender, RoutedEventArgs e)
{
media2.Stop();
}
private void PauseMedia2(object sender, RoutedEventArgs e)
{
media2.Pause();
}
private void PlayMedia2(object sender, RoutedEventArgs e)
{
media2.Play();
}
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<MediaElement x:Name="media1" Source="1.mp3" Margin="0,151,0,359" />
<MediaElement x:Name="media2" Source="2.mp3" Margin="0,154,3,359" Grid.Column="2" />
<!-- Stops media playback.-->
<Button Click="StopMedia1" Content="Stop" Margin="6,449,24,244" />
<!-- Pauses media playback. -->
<Button Click="PauseMedia1" Content="Pause" Margin="0,538,24,143" />
<!-- Begins media playback. -->
<Button Click="PlayMedia1" Content="Play" Margin="0,649,0,47" />
<Button Click="PauseMedia2" Content="Pause" Grid.ColumnSpan="2" Margin="154,524,6,169" Grid.Column="1" />
<Button Click="PlayMedia2" Content="Play" Grid.Column="2" Margin="0,612,12,59" />
<Button Click="StopMedia2" Content="Stop" Margin="18,429,12,264" Grid.Column="2" />
</Grid>
提前致谢。
答案 0 :(得分:1)
不,在Windows Phone 7 / 7.5中无法同时播放两个MediaElements。 要做到这一点,你需要使用XNA的SoundEffect类,尽管我认为它不支持流式传输。