Ever have those times that you’d like to share a piece of media but have it start at a particular time? I did recently, and figured I’d share my solution.
It turns out, WordPress does not support this feature out of the box (though you could argue, theoretically, that it should).
We just remembered the 50 year anniversary of the Selma march which was nicknamed Bloody Sundy as 600 civil rights marchers were attacked viciously by law enforcement in 1965. It seems appropriate to sample the MLK “I have a dream speech for this demo.
Now of course, it’s all a great speech worth listening to, but what if I want to start the audio at the place we all know?
Boom, just like that. The nuts and bolts of this are tied up in this code:
Simply, I filter the shortcode attributes for the audio and video shortcodes adding a new argument – “start”. This is in seconds.
The second adds a little snippet of Javascript after each embed that moves the internal time pointer to the appropriate spot in the supplied media.
Caveat: This will not work for media that is simply cut and paste. While WordPress will translate appropriate media URLs into embeds, it does not pass anything more than the required `src` argument.
Full source code, as a WordPress plugin, can be found on Github. (Pull requests encouraged)