Embedded video
From CONTENTdm Users Wiki
It's been quite a while since I did this, but here are some guiding points. Let me know what isn't clear.
Goal: have video items display embedded in the basic_view.php page rather than the
link to the video.
CCDL choose H264, an open standard video format. Currently only QuickTime implements this standard. (As opposed to Real Player or Windows Media which are the only implementations of their respective non-standards.) The format of the video is mostly irrelevant to this article, except in that it dictates what type of html markup and browser plugins are needed to display an embedded video to users of your site.
Contents |
[edit] step 1: represent your video as a CONTENTdm item
I originally considered using CONTENTdm's built in URL item type to represent streaming videos and to look for URLS with the rtsp:// (real time streaming protocol) scheme. However, at CCDL we had a secondary goal of having multiple bit-rates of each video available to better serve patrons with different speeds of internet connection. CONTENTdm does not support multiple views of a single item and using a compound object for this didn't seem like the right thing. Because of this requirement we decided to represent each video item as an html file, called a video link bundle or video bundle, within CONTENTdm. The video bundle is a snippet of html contained multiple links pointing at our streaming server. (CCDL's streaming server is a different machine than the CONTENTdm server, but they could just as easily be the same physical hardware.)
Example Video Link Bundle for item What was postmodernism
<!-- file: cdl00004.mov.html -->
<ul>
<li><a href='http://streaming.libraries.claremont.edu/cdl/cdl00004_040.mp4' class='qt6'>40 Kbps</a> (Dial Up. Requires QuickTime 6)</li>
<li><a href='http://streaming.libraries.claremont.edu/cdl/cdl00004_300.mov' class='qt7'>300 Kbps</a> (DSL/Cable. Requires QuickTime 7)</li>
<li><a href='http://streaming.libraries.claremont.edu/cdl/cdl00004_800.mov' class='qt7'>800 Kbps</a> (DSL/Cable. Requires QuickTime 7)</li>
<li><a href='http://streaming.libraries.claremont.edu/cdl/cdl00004_lan.mov' class='qt7'>LAN</a> (Recommended for on campus. Requires QuickTime 7)</li>
</ul>
Each url falls into a pattern so you could imagine having basic_view.php generate this set of links automatically each time the item is viewed from a single url or bit of metadata in the item. Having video link bundles as snippets of html leaves a lot of flexibility open for per item customizations: each item could have any number of links and is free to label them as any bit-rates it wants, and may even violate the standard file naming conventions. (Some items may not be available at high bit-rates or may be multiple segments e.g. chapters of a single item.) This leaves a lot of flexibility for a future containing even higher bit rates or different formats, such as WMV or Real Player.
Notice that each link has a class to denote which version of QuickTime is required to view it.
[edit] step 2: having CONTENTdm do special things to your video items
Notice that the name of the video link bundle file ends in .mov.html. This allows basic_view.php<code> to make a decision about how to display this type of file. I used filename because CONTENTdm already used the <code>.pdf extension as a special case. However, to it's disgrace, CONTENTdm really likes to rename whatever files you upload to it, and it does so by destroying everything but the last extension. You have to be really careful in order to prevent that. See another article preventing CONTENTdm from renaming your files. The point is that you should strongly consider making your determination that "this item is a video" based on a metadata field instead of the file name.
For CCDL's implementation the special code is: display the contents of the video link bundle directly to the user, along with some special javascript, and the icon of the item.
(I'll post the actual code to this later, if I can)
Your implementation could do anything you want: database lookups to determine available bit rates, generate html, calculate large prime numbers.
All of this is done by creating new else if statements in basic_view.php. See Pdf viewing article for some more examples.
[edit] step 3: creating the embedded controller
Briefly: I used javascript to dynamically create an embedded QuickTime plugin and change the source url of the video when each link is clicked. I also added messages abut which versions of QuickTime are required.
If the user doesn't have javascript or QuickTime the experience degrades cleanly into a list of links and the user is free to do with them as they please. After-all, there may be new ways of displaying H264 content that I don't know about.
The html markup needed for a controller to display your type of video (QuickTime, Real Player, WMV, flash) can be found in online tutorials (e.g. here, or direct from apple). The javascript commands to manipulate (start, stop) the controller can also be found online (e.g. Introduction to JavaScript Scripting Guide for QuickTime). It's not that I'm telling you to rtfg in a mean way, it's just that I don't know everything. (well duh).
I need to get ready for work so I'll finish this up later.

