0

我将编写一个应用程序,它将同时从 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> 

提前致谢。

4

1 回答 1

1

不,在 Windows Phone 7/7.5 中不能同时播放两个 MediaElement。为此,您需要使用 XNA 的SoundEffect类,尽管我认为它不支持流式传输。

于 2012-06-28T20:41:45.003 回答