Search code examples
c#.netwindows-phone-7windows-phone-8mytoolkit

MyToolkit You Tube API. Video Player Crash in windows phone 7


I'm trying to create and app with inbuilt capability to watch You tube videos. The plugin that I am using to implement this feature is "MyToolKit"(http://mytoolkit.codeplex.com/). The whole thing works fine. When the request query is sent to the API, the videos and thumbnails appear correctly. But when selected a specific movie, an exception is thrown and Visual Studio breaks to the debugger. The following is the code at the Video Selection point.

private void Grid_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            Grid tappedGrid = sender as Grid;
            YouTubeVideo selectedVideo = tappedGrid.DataContext as YouTubeVideo;
            string videoId = selectedVideo.YouTubeVideoId;
            try {
                YouTube.Play(videoId, YouTubeQuality.Quality480P, e1 => { if (e1 != null) { MessageBox.Show(e1.Message); } });
            }
            catch(Exception e1){
                MessageBox.Show(e1.Message.ToString());
            }

           // MessageBox.Show(videoId);
        }

The exception is thrown and the debugger breaks into the application generic exception(App.xaml.cs) Although the exception is handled as shown above, which i thought is the place at which the exception occurs. Hence the debugger/app crashes. The video continues to play at the Default Video Player. Any suggestions on how to solve this?.

Exception Details System.Runtime.Serialization.InvalidDataContractException was unhandled Message: An unhandled exception of type 'System.Runtime.Serialization.InvalidDataContractException' occurred in Microsoft.Phone.Interop.ni.dll


Solution

  • Unless you're doing anything with Page.State or Application.State or other serialization on navigation it looks like an issue with the library you're using. Raise with them.