에서 다시 후 복원 재생되지 않습니다. 따라서 App.xaml의 리소스로 유지해야했습니다.MediaElement에 내가 페이지에 걸쳐 음악을 재생하기 위해 사용하십시오 MediaElement에이 삭제 표시
상황이 내 WP의 윈도우 버튼을 누를 때까지 예상대로 작동합니다. 응용 프로그램에 삭제 표시가 나타나고 MediaElement가 예상대로 재생을 중지합니다. 내 Application_Deactivated에, 나는 명시 적으로 Player.Stop()를 호출
내가 응용 프로그램을 복원 할 때 문제가 발생합니다. 다른 모든 상태는 복원되지만 미디어 요소는 음악을 재생하지 않습니다. 나는 음악에 책임이있는 코드가 타격을 입었음을 알 수 있지만 MediaElement의 MediaOpened는 실행되지 않습니다. 나는 명백한 것을 놓치고 있는가?
편집
public MediaElement player = null;
private void InitializeMusic()
{
if (App.Current.Resources.Contains("ME"))
{
player = App.Current.Resources["ME"] as MediaElement;
}
player.MediaOpened += player_MediaOpened;
}
나는 다시 그것을 초기화하고 ... 난라는 방법을 가지고, 내 App.xaml.cs를에서
<Application.Resources>
<MediaElement x:Name="ME" MediaEnded="RepeatMedia" Volume="1" AutoPlay="False" Height="0" Source="/Sounds/mywave.wav" />
</Application.Resources>
을 [KeyboardP의 질문에 명확히] ...
// Code to execute when the application is activated (brought to foreground)
// This code will not execute when the application is first launched
private void Application_Activated(object sender, ActivatedEventArgs e)
{
InitializeMusic();
}
? 은'MediaElement'는이 추가 된 전에 재생을 시도 할 수 있도록이 재생되기 전에 시각적 트리에 추가 할 수 있습니다. – keyboardP
키보드 keyboardp에 감사드립니다. 세부 사항을 명확하게하기 위해 질문을 편집했습니다. –