What is the best way to develop a video player from scratch?

Asked

Viewed 402 times

2

Well, I would like to know what topics, articles books finally references would help me in the task of developing a video player from scratch as the average classic player for example?

1 answer

2


I once had the task at work of creating a video player from scratch C#.

In reality, the Framework would take care of the worst part of the work, so I would only have to "implement" and put the pieces of the puzzle together. Today I confess that C# it was not yet my strong suit (and it is not yet), but like every good driver: give me the key and I will drive.

Today I see that part of the challenge would have been less if there had been the proper planning that was not at all great, because, I repeat, the Framework would take care of a good part of the carpenter. However, the daily exfoliation behind a single goal and given the short deadlines that we professionals of the area are constantly submitted made me deliberately "decorate" and have a much more analytical and macro view of the thing, so that you can consider this content as important for your walk.

1. Planning

It is essential. So if you can answer these questions, part of the outline of your goal will have already been solved:

  • What your video player will have?
  • The controls (play, pause, stop, forward and backward) will be customizable?
  • There will be an option fullscreen? What is the position of this icon?
  • There will be option of legenda? Will this caption be chosen on the hard drive by the user? This caption will be used automatically if there is a file .srt with the same video name and in the same video folder?
  • What are the métodos of this new class?
  • What are the eventos of this new class? (perhaps the most important)
  • The controls (as class properties) will have public access (for greater "control" of the visual elements)?

2. Properties

The ones I can highlight:

  • IsPlayerMounted (right after the last line of the method mountPlayer())
  • IsPlayerReady (right after uploading the video and it is ready for action)
  • IsPlaying (bool)
  • IsPaused (bool)
  • IsStopped (bool)
  • IsInFullscreen (bool)

3. Methods

The most common methods, I can already tell you (and are self descriptive):

  • MontaPlayer() (updates IsMounted)
  • Play() (updates IsPlaying, IsPaused and IsStopped)
  • Pause() (updates IsPlaying, IsPaused and IsStopped)
  • Stop() (updates IsPlaying, IsPaused and IsStopped)
  • Backward()
  • Forward()
  • Fullscreen()
  • Destroy() (updates much of the above properties)

4. Events

Perhaps the most important part of the problem is where everything happens. "When giving play", "when pausing", "when stopping", "when giving fullscreen", timming is all in a video player. You certainly wouldn’t want a delay when playing or the button play take time to appear after giving pause or stop, right? Then implement some events with delegates make the video player application richer and with more features.

Some events I used (are self-describable):

  • OnMount()
  • OnReady() (useful to implement a property autoPlay = true for example or even autoFullSreenOnPlay = true for example)
  • OnPlay()
  • OnPause()
  • OnStop()
  • OnDestroy()

5. Sequence diagram

Here, crudely sketched:

() User loads the video -> class mounts the visual controls (frame, video controls) -> class loads the video in the corresponding control (ex.: MediaElement in the WPF) -> fullscreen (if applicable) -> video is started (if AutoPlayOnReady = true) -> start caption (if applicable)

6. Screenshot

Below some screenshots of the whole idea implemented:

enter image description here

enter image description here

enter image description here

Completion

Most of the work is actually getting the pieces to fit together. Whatever language you choose, the concept will always be the same.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.