Windows Phone 용 Silverlight에서 MediaElement
컨트롤에 문제가 있습니다. 사용자가 단추를 누를 때 두 가지 색조를 재생하는 것이 목표입니다. 이렇게하기위한 방법은 각 음색에 대해 MediaElement
을 갖는 것입니다. (아마도 더 좋은 방법이 있나요?)Silverlight의 MediaElement 관련 문제
<phone:PhoneApplicationPage
x:Class="MediaElementTest.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True">
<StackPanel x:Name="LayoutRoot" Background="Transparent">
<MediaElement
x:Name="firstTone"
MediaEnded="firstTone_MediaEnded"
Source="{Binding FirstTone}" />
<MediaElement
x:Name="secondTone"
Source="{Binding SecondTone}" />
<Button Content="Play" Click="Button_Click" />
</StackPanel>
</phone:PhoneApplicationPage>
코드 숨김
public partial class MainPage : PhoneApplicationPage
{
public Uri FirstTone
{
get
{
return new Uri("A.mp3", UriKind.Relative);
}
}
public Uri SecondTone
{
get
{
return new Uri("B.mp3", UriKind.Relative);
}
}
public MainPage()
{
InitializeComponent();
LayoutRoot.DataContext = this;
}
private void Button_Click(object sender, RoutedEventArgs e)
{
firstTone.Stop();
secondTone.Stop();
firstTone.Play();
}
private void firstTone_MediaEnded(object sender, RoutedEventArgs e)
{
secondTone.Play();
}
}
내가 버튼을 클릭
는 더 톤이 연주되지 않습니다. 왜 이런거야? 내가 도대체 뭘 잘못하고있는 겁니까?
재생할 두 톤은 런타임까지 알 수 없습니다. (만약 내가 가능한 모든 조합을 미리 만들었다면 많은 양의 파일이 될 것입니다. 프로그래밍 방식으로 처리하려고합니다.) –
오, 알았습니다.아무도 다른 사람들이 같은 제안을하지 않도록 내 답변을 남겨 둘 것입니다. – MusiGenesis
내 생각 엔 우리스에 뭔가 문제가있는 것 같습니다. 온라인으로 코드 샘플을 찾아서 점차적으로 수정하는 것이 좋습니다. – MusiGenesis