locked
C++ Metro App with Video Playback, Keyboard Input, and Image Overlays

    Question

  • Hello All,

    I'm trying to develop a Metro App where a video plays, I'm able to control it with keyboard input, and also have images displayed over the video.

    Now I've researched a few methods but it seems like I'm stuck with only two of the three problems resolved at a time. The first is I'm using an XAML UI to display the images, using the simple <Image> class and having a <MediaElement> to play the video with the images over top of the video. However, I'm having a lot of problems understanding how to get the keyboard and mouse event handlers are called. I've tried putting the "KeyDown" event in the <MediaElement>, also in the <Grid>, which holds the <MediaElement>. I've even tried putting it in the <UserControl> at the very top, but that also did nothing (which I assumed it would but I thought it couldn't hurt). I've read several threads about having to get the CoreWindow to handle all of the message from the keyboard, and that would be fine, if I knew how to get into the C++ code in order to access the CoreWindow.

    So my question in scenario 1, is just how to get my program to recognize that I've pressed a keyboard button, so that I'm able to handle it. I should mention that I know what I'm doing when it comes to the C++, but I'm very new to the XAML. I just really enjoy how easy it is to do clean UIs with it, so I'm giving it a try.

    For scenario 2, I've looked at the Media Engine Playback Sample. This handles the keyboard input (through the CoreWindow strictly in C++), and it handles the video playing. However, displaying images, causes me to use either DirectX (which I have very little experience with) or the Windows.Graphics.Imaging namespace. I'd be happy to use the namespace, but I haven't found anything specific of how to render the images on the screen, and I don't know if that is even able to display the images, with the video playing in the background (I've run into a lot issues doing this, and I know that often images are over written by the video).

    My question, would be basically, is there anywhere that explains the Imaging namespace in more depth as to how to use it to display images? Or if anyone knows of a nice way to have video and images blend over top of each other in DirectX?

    I understand I'm probably asking for a lot, but I would appreciate any help you guys would have, I've been working with these problems trying to read and understand all week with no luck.

    Thanks,

    Alex.

    Friday, January 27, 2012 7:24 PM

Answers

  • Hi Alex,

    Please post separate questions in separate posts. It is much easier to keep track that way.

    You can get a CoreWindow object from Windows::UI::Xaml::Window::Current->CoreWindow. Take a look at the CoreWindow sample for more information on how to handle its KeyDown events.

    The Windows.Graphics.Imaging namespace doesn't render, it allows encoding and decoding files. From there you can stream the image into a BitmapSource to display in your Image control. There are several samples that demonstrate using images.

    --Rob

     

    • Marked as answer by Bob_Bao Tuesday, February 7, 2012 6:41 AM
    Thursday, February 2, 2012 3:09 AM
    Owner

All replies

  • Hi Alex,

    Please post separate questions in separate posts. It is much easier to keep track that way.

    You can get a CoreWindow object from Windows::UI::Xaml::Window::Current->CoreWindow. Take a look at the CoreWindow sample for more information on how to handle its KeyDown events.

    The Windows.Graphics.Imaging namespace doesn't render, it allows encoding and decoding files. From there you can stream the image into a BitmapSource to display in your Image control. There are several samples that demonstrate using images.

    --Rob

     

    • Marked as answer by Bob_Bao Tuesday, February 7, 2012 6:41 AM
    Thursday, February 2, 2012 3:09 AM
    Owner
  • Hey Rob,

    Thanks for responding, I thought that these were related enough for one post. My apologies!

    I'll take a look at these, thanks.

    Monday, February 6, 2012 2:05 PM