我正在爲MediaPlayerElement創建CustomMediaTransportControls。在這我想要一個按鈕來創建CompactOverlay框架,所以我將下面的代碼添加到public sealed class CustomMediaTransportControls : MediaTransportControls
。嘗試讀取或寫入受保護的內存。這通常表示其他內存已損壞
public async void CompactOverlayButton_ClickAsync(object sender, RoutedEventArgs e)
{
await CoreApplication.CreateNewView().Dispatcher.RunAsync(CoreDispatcherPriority.Normal,() =>
{
var frame = new Frame();
compactViewId = ApplicationView.GetForCurrentView().Id;
frame.Navigate(typeof(VideoPlayerPage));
Window.Current.Content = frame;
Window.Current.Activate();
ApplicationView.GetForCurrentView().Title = "";
});
bool viewShown = await ApplicationViewSwitcher.TryShowAsViewModeAsync(compactViewId, ApplicationViewMode.CompactOverlay);
}
但是,當我使用這些代碼時,我在XAML部分中收到錯誤消息。 如果我沒有使用上述功能,則不會有錯誤。
解決方案的嘗試:
在PowerShell中
運行netsh winsock reset
結算解決方案和重建方案
僅供參考:
這裏是我的全部代碼
- CustomMediaTransportControls.cs -
ResourceDictionary
- MediaPlayerDictionary.xaml - 從
MediaTransportControls
派生類 - VideosPage.xaml - 頁面,
CustomMediaTransportControls
已使用
'CustomVideoControls'是你開發的東西嗎?它是否使用了不安全的{}塊? – Milney
@Milney我會附上問題 –
中的全部代碼,你能提供完整的xaml代碼嗎? – Hannes