Click here to Skip to main content
15,946,320 members
Articles / Programming Languages / C#
Tip/Trick

Video Player supporting Segment Definitions

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
10 Aug 2020CPOL8 min read 5.2K   410   2   1
An application to define, save and watch segments of a video that I have selected
An application that I developed for my own use that allows me to load a video, then define, play and save multiple segments. It will save information about the videos and their associated segments in the XML file associated with the application. It includes features like being able to change the speed, and naming segments.

Introduction

I am an avid Argentine Tango Nuevo style dancer. I will often watch videos, and when I see some of the moves, I like to try to duplicate them. I use the video as a guide, but trying to figure out the subtleties of the move from a video of a few minutes can be difficult since the move lasts for only seconds. I have some tools that will allow me to cut a segment out of a clip, but it is hard in the static environment I was using to figure out where I should snip. The other issue is that if there are several moves I want to review, then I end up with all these clip files. Then there is the issue of being dance, how do you label a file so that it makes sense when you look at the name, particularly with a street dance like Argentine tango. So, the idea was to be able to set a segment, or even several segments, and when you open a file, the segments are available. The nice thing is that now if you are looking at the segment, and you want to change the start or end times slightly, it is now possible.

This was functionality that combined did not seem to be available in any application I have seen. Just using the slider had issues including it was hard to find the right point with the mouse. Some applications like VLC had the ability to jump back say 10 seconds, which is often much better than just using the slider. Also could just leave the pointer at a certain point on the slider but hard to get the right spot. And if you need to change the position, or move the mouse pointer for some other reason, lose your place.

When I came with the idea that such an application would make my life so much easier, I was also developing an idea to help with the listening to language tapes. That was a bit simpler in coming up with the interaction, and to have something useful, only needed to worry about the track being played. Having maintain information about the track, or the list of tracks that one is listing to was not that important, just nice--With language tracks, I find I have to review the material many times before I am comfortable with the material but it is also good to progress, so I will have several tracks that I will listen to, and then repeat. As I get more comfortable with the material, I will drop tracks and add more advanced tracks.

So I started developing the Audio Player first. And when I finally got to the video segment player, I did find that there was a lot of thought I had to put into the UI and the design in general. I used a number of components from the Audio player, and some could be used pretty much unchanged, but others needed a lot of modification. I also did some things better as I progressed, and did change the audio player to have more in common with the video segment player.

Image 1

Usage

There are three groups of buttons with arrow keys and a TextBox: left, right, center.

  • The left and right group are for the left and right end of the current segment respectively. They each have a text box showing the time in minutes, seconds and 10ths of seconds. The left and right arrow controls on either side will move the respective end of the segment a specific number of seconds left and right. Using the Alt, or Control key will change the number of seconds. Initially, this is set to 1 second with no modifier key, 5 seconds with the alt key depressed, and 20 seconds with the control key pressed. If the shift key is also depressed, then the segment length will be maintained as the segment start or end is moved the same number of seconds. The time for the extents can also be changed from the TextBox, and when a digit is selected, then the up and down arrow keys will also work.
  • The center group is for playing the video. There is a button next to the TextBox that switches between play and pause. If this button has the pause symbol, the video is playing, otherwise it is paused. Outside of this, there are arrow keys that will move the current play position a specific number of seconds left and right specifically. Using the Alt, or Control key will change the number of seconds. Initially, this is set to 1 second with no modifier key, 5 seconds with the alt key depressed, and 20 seconds with the control key pressed. When only the shift key is pressed, then the previous or next segment associated with the video will be loaded respectively. If the shift and control key are pressed, then the previous or next video in the Active Video Files list will be loaded. Outside of these controls are arrow keys with a different shape. These arrow keys will set that the associated side of the segment to the current playing position.
  • On one side of this center group inside the left set of controls are two toggle buttons. One is used to cause the video to repeat, which means as soon as the video completes, it will start play again when the toggle button is activated, otherwise the video track will go into pause mode and the play position will be on the left side of the video track. The other button will switch between the play track being the full video and only the segment so that the left end of the play track represents the start of the segment and the right end represents the end of the segment.
  • On the other side is a ComboBox which will change the speed of the video.
  • Above these controls is the slider that will display and control the play position, and the segment which extends the width of the window.  When the full video is being played, the main slider whose thumb is a green circle shows the relative position on of the play position within the video. The play position can be changed either by dragging the thumb or clicking on the track will move the video play position and the thumb to that position. In the background of this slider, the extent of the segment is displayed as a lighter shade than the background. Under this slider are two more thumbs shaped as triangles that will move the ends of the segment.
  • When the toggle button for the segment only is depressed, then the slider will be only for the segment as currently defined. The left end of the slider will be the start of the segment and the right end with be the end of the segment. There will be no background that shows the extent of the segment and the two thumbs that control the ends of the segment will also be collapsed.

There is also a context menu that is accessed by right clicking on the window.

  • Show Settings Window: This will bring up the Settings Window which will allow certain aspects of the application to be controlled. The window is closed with the button at the upper right corner.
  • Show Videos Window: This will bring up show files that can be opened directly. There are three lists of videos that can be paged through with the button with the hand pointing right icon, or directly using the context window that is brought up by clicking on the icon at the top left of the window. The Recent Videos list is automatically populated as videos are opened. The currently playing video can be added to the active list using the button with the plus sign on the button left, or using drag and drop. The third list general contains those videos that the user had deleted from the active list and is intended to allow the user to keep the information associated with those videos without cluttering up the active videos list. The window is closed with the button at the upper right corner.
  • Another feature available on the context menu is the ability to rotate the video by increments of 90 degrees. The angle is saved with the Video file information, so once set, does not have to be set again.vz

Using the Code

There are a number of interesting features in the design, and if anyone is interested I will write up anything that anybody would like explained.

History

This application is still being worked on and I will include updates as I enhance the application.

  • 20/08/10: Initial version
  • 20-08/15: Few bug fixes, Added the ability to import and export settings and the audio file information, fixed issue with context menu icon size when running in Windows 7, tweeks to sizes and margins of controls, fixed issues with handling double settings.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Clifford Nelson Consulting
United States United States
Has been working as a C# developer on contract for the last several years, including 3 years at Microsoft. Previously worked with Visual Basic and Microsoft Access VBA, and have developed code for Word, Excel and Outlook. Started working with WPF in 2007 when part of the Microsoft WPF team. For the last eight years has been working primarily as a senior WPF/C# and Silverlight/C# developer. Currently working as WPF developer with BioNano Genomics in San Diego, CA redesigning their UI for their camera system. he can be reached at qck1@hotmail.com.

Comments and Discussions

 
QuestionDoes not run under Windows 10 ? Pin
Member 1622007611-Mar-24 5:54
Member 1622007611-Mar-24 5:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.