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
  1. Home
  2. General Programming
  3. C#
  4. How to clone a videoPlayer trackbar?

How to clone a videoPlayer trackbar?

Scheduled Pinned Locked Moved C#
helpquestiontutorialcareerlearning
10 Posts 3 Posters 0 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.
  • _ Offline
    _ Offline
    _Q12_
    wrote on last edited by
    #1

    First of all, HNY2019 to codeproject comunity. You are doing a very good job! I am learning how to use WindowsMediaPlayer control. My (new) track bar is a fixed length (200px) Empty control with a Paint red rectangle inside it, that updates videoplayer Current time. I am stuck at a strange point that i cant manage to see the solution. I bet is a simple solution and i am too tired and foggy to see it right now. The problem is the Maximum Length of the Movie. It is changing every time when i load a new movie, right so far? Now, my fixed track bar has 200px. How do i make 200px into 1600 int length? So sorry for my bad english explanation. Basically, i want to clone a videoPlayer trackbar. Thank you.

    D OriginalGriffO 2 Replies Last reply
    0
    • _ _Q12_

      First of all, HNY2019 to codeproject comunity. You are doing a very good job! I am learning how to use WindowsMediaPlayer control. My (new) track bar is a fixed length (200px) Empty control with a Paint red rectangle inside it, that updates videoplayer Current time. I am stuck at a strange point that i cant manage to see the solution. I bet is a simple solution and i am too tired and foggy to see it right now. The problem is the Maximum Length of the Movie. It is changing every time when i load a new movie, right so far? Now, my fixed track bar has 200px. How do i make 200px into 1600 int length? So sorry for my bad english explanation. Basically, i want to clone a videoPlayer trackbar. Thank you.

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      You're not cloning anything. All you're doing is mapping a number range onto another number range, or a simple percentage. Your trackbar simply goes from 0 to 100%. This is grade school math. At 200 pixels wide, each pixel represents 0.5%. When your video is playing, you get the percentage played by dividing the number of seconds played by the total number of seconds in the video. You'll get a number between 0 and 1, your percentage played.

      Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
      Dave Kreskowiak

      _ 1 Reply Last reply
      0
      • D Dave Kreskowiak

        You're not cloning anything. All you're doing is mapping a number range onto another number range, or a simple percentage. Your trackbar simply goes from 0 to 100%. This is grade school math. At 200 pixels wide, each pixel represents 0.5%. When your video is playing, you get the percentage played by dividing the number of seconds played by the total number of seconds in the video. You'll get a number between 0 and 1, your percentage played.

        Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
        Dave Kreskowiak

        _ Offline
        _ Offline
        _Q12_
        wrote on last edited by
        #3

        i still dont get it. put an example there too please.

        D 1 Reply Last reply
        0
        • _ _Q12_

          i still dont get it. put an example there too please.

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          It's simple. You played 1200 seconds of a 1600 second video. That's 1200/1600 = 0.75, or 75% of the video played. Your trackbar is 200 pixels wide, for 100%, so each pixel represents 0.5%, or put another way, 2 pixels represents every 1%. So, you draw your marker 75 * 2 pixels over from it's start.

          Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
          Dave Kreskowiak

          _ 1 Reply Last reply
          0
          • _ _Q12_

            First of all, HNY2019 to codeproject comunity. You are doing a very good job! I am learning how to use WindowsMediaPlayer control. My (new) track bar is a fixed length (200px) Empty control with a Paint red rectangle inside it, that updates videoplayer Current time. I am stuck at a strange point that i cant manage to see the solution. I bet is a simple solution and i am too tired and foggy to see it right now. The problem is the Maximum Length of the Movie. It is changing every time when i load a new movie, right so far? Now, my fixed track bar has 200px. How do i make 200px into 1600 int length? So sorry for my bad english explanation. Basically, i want to clone a videoPlayer trackbar. Thank you.

            OriginalGriffO Offline
            OriginalGriffO Offline
            OriginalGriff
            wrote on last edited by
            #5

            Simple: each pixel in your trackbar represents a variable amount of time: 0.5% of the total length of the movie. So if your movie is 55 minutes and 37 seconds long, each pixel represents (55 * 60 + 37) * 0.005 == 16.685 seconds. If your movie is 2 hours, 12 minutes, and 14 seconds long, then each pixel is (((2 * 60) + 12) * 60 + 14) * 0.005 == 39.67 seconds Get the idea?

            Sent from my Amstrad PC 1640 Never throw anything away, Griff Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!

            "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
            "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

            _ 1 Reply Last reply
            0
            • D Dave Kreskowiak

              It's simple. You played 1200 seconds of a 1600 second video. That's 1200/1600 = 0.75, or 75% of the video played. Your trackbar is 200 pixels wide, for 100%, so each pixel represents 0.5%, or put another way, 2 pixels represents every 1%. So, you draw your marker 75 * 2 pixels over from it's start.

              Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
              Dave Kreskowiak

              _ Offline
              _ Offline
              _Q12_
              wrote on last edited by
              #6

              Thank you mister Dave Kreskowiak - very nice answer!

              1 Reply Last reply
              0
              • OriginalGriffO OriginalGriff

                Simple: each pixel in your trackbar represents a variable amount of time: 0.5% of the total length of the movie. So if your movie is 55 minutes and 37 seconds long, each pixel represents (55 * 60 + 37) * 0.005 == 16.685 seconds. If your movie is 2 hours, 12 minutes, and 14 seconds long, then each pixel is (((2 * 60) + 12) * 60 + 14) * 0.005 == 39.67 seconds Get the idea?

                Sent from my Amstrad PC 1640 Never throw anything away, Griff Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!

                _ Offline
                _ Offline
                _Q12_
                wrote on last edited by
                #7

                ok i solve it. I forgot a very old and very useful rule... heh. All good now. Thank you.

                OriginalGriffO 1 Reply Last reply
                0
                • _ _Q12_

                  ok i solve it. I forgot a very old and very useful rule... heh. All good now. Thank you.

                  OriginalGriffO Offline
                  OriginalGriffO Offline
                  OriginalGriff
                  wrote on last edited by
                  #8

                  You're welcome!

                  Sent from my Amstrad PC 1640 Never throw anything away, Griff Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!

                  "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                  "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                  _ 1 Reply Last reply
                  0
                  • OriginalGriffO OriginalGriff

                    You're welcome!

                    Sent from my Amstrad PC 1640 Never throw anything away, Griff Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!

                    _ Offline
                    _ Offline
                    _Q12_
                    wrote on last edited by
                    #9

                    another devil now - with progressBarX1_Click. And...Resolved! I wish i can Delete this thread. The "delete" link Button from the top, is showing this time(Haleluia), but is greyed out and I can not use it. Probably is a thing for those with money. I am thinking too much probably. :) But seriously, this is a ... (my) fart thread, that i wish to smudge it.

                    OriginalGriffO 1 Reply Last reply
                    0
                    • _ _Q12_

                      another devil now - with progressBarX1_Click. And...Resolved! I wish i can Delete this thread. The "delete" link Button from the top, is showing this time(Haleluia), but is greyed out and I can not use it. Probably is a thing for those with money. I am thinking too much probably. :) But seriously, this is a ... (my) fart thread, that i wish to smudge it.

                      OriginalGriffO Offline
                      OriginalGriffO Offline
                      OriginalGriff
                      wrote on last edited by
                      #10

                      No, it's simply that you can't delete any post with a response: it would leave the response "hanging in midair" with no support, screaming and wetting itself in terror (Posts are scared of heights, as I'm sure you know). And of course you have no authority to delete other peoples posts, so you can't get rid of it!

                      Sent from my Amstrad PC 1640 Never throw anything away, Griff Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!

                      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                      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