Fight the media monster

Media Voodoo

For the most people, controlling video and audio players was like fighting with a huge, mighty and creepy monster. They know what they were doing, but they don’t know how to control them.

Controlling media players seemed to be something like voodoo.

But if you step back, calm down and take a closer look at the monster, you will see that the monster isn’t huge, mighty or creepy. You will notice that it’s not even a monster at all.

Every API is created by people just like you and me. They have the same problems and the same issues to fight with. Most of the APIs are easy to tame and handle.

The APIs

A media player usually needs an included javascript file which contains the API.
It doesn’t matter if it’s the YouTube, soundcloud, Brightcove or the VIMEO API.

This file often offers you main objects and some herper objects, e.g. event handler objects.
The only exception is the html5 video player. The API of this player is already included in the browsers.

The player

Getting a player returned as an object is generally the same. One makes a new instance of the main API object and passes it to the DOM element or the DOM elements id.

The methods

Here all the players are the same. Every player API offers a play, pause, seek and complete method. Some player APIs offers more functionality and some less. Sometimes the methods are named a bit different. For example the youtube players play method is called playVideo() instead of play(). But if that is the biggest difference, so what!

Just take a closer look at the player API documentations and you will see that there are pretty close to each other.

Exceptions

Of course there are always exceptions. Some players needs a different handling than the others. Some players don’t make their properties public so you have to call a get function with a callback. The complete event from old Brightcove smart player is also a bit tricky in that it fires the callback only the first time the video has completed. If you restart the player and it ends a second time, the event won’t fire. The trick here is to hook into progress of the event and compare the position within the duration. So we will know when the video has completed.

After a while you will begin to enjoy playing with the media players and their APIs.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>