Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. WCF and WF
  4. Images and Video in same MediaElement??

Images and Video in same MediaElement??

Scheduled Pinned Locked Moved WCF and WF
question
6 Posts 2 Posters 65 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Red_Wizard_Shot_The_Food
    wrote on last edited by
    #1

    Hi, I have a List<> of URI's that point to either images or videos... What I'm after (in simplified tearms) is getting a MediaElement to show the media in the list one after the other, with video playing to it's full duration (or a pre-determined length) and images being shown for 1 second. Currently I have a MediaElement with it's "MediaEnded" event hooked up to a method that switches the MediaElement source to the next URI in the List. But as default this shows images for ~3 seconds (which I found odd... do images actually "End" like a video does?? and why ~3 seconds??) and then blinks the media element black between each source change. Could anyone suggest a sollution? Thanks.

    L 1 Reply Last reply
    0
    • R Red_Wizard_Shot_The_Food

      Hi, I have a List<> of URI's that point to either images or videos... What I'm after (in simplified tearms) is getting a MediaElement to show the media in the list one after the other, with video playing to it's full duration (or a pre-determined length) and images being shown for 1 second. Currently I have a MediaElement with it's "MediaEnded" event hooked up to a method that switches the MediaElement source to the next URI in the List. But as default this shows images for ~3 seconds (which I found odd... do images actually "End" like a video does?? and why ~3 seconds??) and then blinks the media element black between each source change. Could anyone suggest a sollution? Thanks.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      You might consider using two media elements. One for images and one for videos. Then just transistion between them. This will get rid of the flash when a video loads. You could also just overlay an image control instead of the second media element.

      Cheers, Karl » CodeProject 2008 MVP » Microsoft MVP - Client App Dev My Blog | Mole's Home Page | MVP Profile

      Just a grain of sand on the worlds beaches.

      R 1 Reply Last reply
      0
      • L Lost User

        You might consider using two media elements. One for images and one for videos. Then just transistion between them. This will get rid of the flash when a video loads. You could also just overlay an image control instead of the second media element.

        Cheers, Karl » CodeProject 2008 MVP » Microsoft MVP - Client App Dev My Blog | Mole's Home Page | MVP Profile

        Just a grain of sand on the worlds beaches.

        R Offline
        R Offline
        Red_Wizard_Shot_The_Food
        wrote on last edited by
        #3

        Thanks, But that really seems to complicate the control of the process... now I have to monitor the media element playing the video, when it's done check to see if the next item is an image, then set the visability on an image to visible and stop the MediaElement playing the video, somehow set the image to display for 1 second before dissappearing, load the next video, start the play process of the MediaElement again repeat. I was really hoping there was a sollution where I can just play any combination of video and image without any flickering between loads and set the play duration depending on what was loaded so basicly do somthing like this: DurationHit()//Called When MediaElement's current duration is up. { Stop() CurrentItem ++; if(MediaItems[CurrentItem] == "image") Duration = 1 else Duration = NaturalDuration Play(MediaItems[CurrentItem]) } Is this not possible ?? (somehow?)

        L 1 Reply Last reply
        0
        • R Red_Wizard_Shot_The_Food

          Thanks, But that really seems to complicate the control of the process... now I have to monitor the media element playing the video, when it's done check to see if the next item is an image, then set the visability on an image to visible and stop the MediaElement playing the video, somehow set the image to display for 1 second before dissappearing, load the next video, start the play process of the MediaElement again repeat. I was really hoping there was a sollution where I can just play any combination of video and image without any flickering between loads and set the play duration depending on what was loaded so basicly do somthing like this: DurationHit()//Called When MediaElement's current duration is up. { Stop() CurrentItem ++; if(MediaItems[CurrentItem] == "image") Duration = 1 else Duration = NaturalDuration Play(MediaItems[CurrentItem]) } Is this not possible ?? (somehow?)

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Red_Wizard_Shot_The_Food wrote:

          play any combination of video and image without any flickering between loads

          Not sure about this, that's where my overlaying and transistion idea came from. More of a workaround than anything else. Just a suggestion.

          Cheers, Karl » CodeProject 2008 MVP » Microsoft MVP - Client App Dev My Blog | Mole's Home Page | MVP Profile

          Just a grain of sand on the worlds beaches.

          R 1 Reply Last reply
          0
          • L Lost User

            Red_Wizard_Shot_The_Food wrote:

            play any combination of video and image without any flickering between loads

            Not sure about this, that's where my overlaying and transistion idea came from. More of a workaround than anything else. Just a suggestion.

            Cheers, Karl » CodeProject 2008 MVP » Microsoft MVP - Client App Dev My Blog | Mole's Home Page | MVP Profile

            Just a grain of sand on the worlds beaches.

            R Offline
            R Offline
            Red_Wizard_Shot_The_Food
            wrote on last edited by
            #5

            Thank you! I sorted it with the help of your answer to my other post :) I made a StoryBoard and MediaTimeline for the MediaElement. Then i used a switch case when reading the List<>... if the current element was an image I set the MediaElement's duration to 1 second and called begin on the StoryBoard and if it was a video I set the duration to the MediaElement's "natural" duration then called begin on the StoryBoard. When you use a MediaTimeline you need to change the source via the MediaTimeline rather then the MediaElement and this seems to solve the problem of the flickering when loading new media :-D

            L 1 Reply Last reply
            0
            • R Red_Wizard_Shot_The_Food

              Thank you! I sorted it with the help of your answer to my other post :) I made a StoryBoard and MediaTimeline for the MediaElement. Then i used a switch case when reading the List<>... if the current element was an image I set the MediaElement's duration to 1 second and called begin on the StoryBoard and if it was a video I set the duration to the MediaElement's "natural" duration then called begin on the StoryBoard. When you use a MediaTimeline you need to change the source via the MediaTimeline rather then the MediaElement and this seems to solve the problem of the flickering when loading new media :-D

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              This solution would make a great article and/or blog post. :cool: Let me know if/when you post it. Glad you were able to get this sorted out, nice work!

              Cheers, Karl » CodeProject 2008 MVP » Microsoft MVP - Client App Dev My Blog | Mole's Home Page | MVP Profile

              Just a grain of sand on the worlds beaches.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups