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

2

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

    
asked by anonymous 04.07.2015 / 05:38

1 answer

2

I once had the task at work to create a video player from scratch in C# .

In reality, the Framework would take care of the worst part of the work, so I could only "implement" and unite the pieces of the puzzle. Today I confess that C# was not yet my strongest (and still is not), 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 was a proper planning that was not even great, because, I repeat, the Framework would take care of a good part of the carpinada. 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 take a much more analytical and macro view of the thing, so that you can consider this content as important to your walk.

1. Planning

It is essential. So if you can answer these questions, some of the outline of your goal has already been resolved:

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

2. Properties

What I can highlight:

  • IsPlayerMounted (just after the last line of the mountPlayer() method)
  • IsPlayerReady (right after loading 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 advance (and are self descriptive):

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

4. Events

Perhaps the most important part of the problem is where everything happens. "When giving play", "while pausing", "while stopping", "while giving fullscreen", timming is all in a video player. You certainly would not want a delay while playing, or the play button seems to delay after giving pause or stop , right? Then implementing some events with% appropriate% make the video player application richer and more resourceful.

Some events I've used (they're self-describing):

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

5. Sequence diagram

Here, roughly sketched:

() User loads video - > class mounts visual controls (frame, video controls) - > class loads the video in the corresponding control (eg OnDestroy() no MediaElement ) - > fullscreen display (if applicable) - > video is started (if WPF ) - > initiates caption (if applicable)

6. Screenshot

Below are some screenshots of the whole idea implemented:

Conclusion

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

    
04.07.2015 / 07:43