나는 App.xaml.cs
이 있습니다홀수 파일 연결 처리 버그
protected override async void OnNavigatedTo(NavigationEventArgs e)
{
FileActivatedEventArgs filesArgs = (FileActivatedEventArgs)e.Parameter;
StorageFile file = (StorageFile)filesArgs.Files[0];
mc.SetSource(await file.OpenReadAsync(), file.ContentType);
mc.Play();
}
그리고이 MainPage.xaml
에 :
protected override void OnFileActivated(FileActivatedEventArgs args)
{
Window.Current.Content = new Frame();
((Frame)Window.Current.Content).Navigate(typeof(MainPage), args);
Window.Current.Activate();
}
이 MainPage.xaml.cs
에
<MediaElement x:Name="mc" />
을 지금, 나는이 직면하고 아주 이상한 문제. 내 응용 프로그램과 .MP4 파일을 연결했습니다. 파일을 열 때마다 즉시 재생되지 않습니다. 예를 들면.
- 나는
a.mp4
을 열어도 재생되지 않으며 앱을 닫지 않습니다. b.mp4
을 열어도 재생되지 않으며 앱을 닫지 않습니다.- 그런 다음
a.mp4
을 열면 재생됩니다. 그렇지 않으면 다시 시도하고 재생됩니다. 이제 MP4 파일을 열면 앱을 종료 할 때까지 아무런 문제없이 재생됩니다.
그래서,이 해결 방법은 가끔 작동합니다
protected override async void OnNavigatedTo(NavigationEventArgs e)
{
FileActivatedEventArgs filesArgs = (FileActivatedEventArgs)e.Parameter;
StorageFile file = (StorageFile)filesArgs.Files[0];
StorageFile file2 = (StorageFile)filesArgs.Files[0];
mc.SetSource(await file2.OpenReadAsync(), file2.ContentType);
mc.SetSource(await file2.OpenReadAsync(), file2.ContentType);
mc.Play();
}
사람이 알고 있나요가 해결하지 않고 작동하지 않는 이유는 무엇입니까?
@Programmer Core 2 Duo 6400에서 테스트했습니다. –
@Programmer'MediaPlayer '를'MediaElement '가있는 페이지에서 호출하여 사용하는 경우 동일한 상황이 발생할 수 있다고 생각하지 않습니다. 나오다. 'MediaElement'는 페이지로드 과정에서로드되고,'FilePicker'를 열면 페이지가 이미로드됩니다. 버그 일 수도 있고 최소한 문서화되지 않은 기능 일 수도 있습니다. [MSDN 포럼] (http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp)에 문제를 게시하면 Microsoft의 많은 사람들이 거기에 있습니다. 또는 [Microsoft Connect] (https://connect.microsoft.com/VisualStudio)에서도 가능합니다. –
@Programmer 제안대로 'MediaOpened' 이벤트를 사용해 보셨습니까? 그것은 당신의 문제를 해결합니까? –