Skip to content

Instantly share code, notes, and snippets.

@sbp
Created December 27, 2011 17:32
Show Gist options
  • Save sbp/1524484 to your computer and use it in GitHub Desktop.
Save sbp/1524484 to your computer and use it in GitHub Desktop.
Create a combined VideoJS file for use with jQuery
#!/usr/bin/env python
import sys, os, shutil, json
out = 'video.combo.js'
if os.path.exists(out):
print >> sys.stderr, 'Error: %s already exists' % out
sys.exit(1)
def alternatives(*names):
for name in names:
if os.path.exists(name):
return name
js = alternatives('video.min.js', 'video.js')
css = alternatives('video-js.min.css', 'video-js.css')
shutil.copyfile(js, out)
with open(out, 'a') as f:
f.write('\n\n')
with open(css) as c:
style = '<style>' + c.read() + '</style>'
f.write('document.write(%s);\n\n' % json.dumps(style))
div = '<div class="video-js-box"></div>'
video = "$('video').addClass('video-js')\n .wrap('%s').VideoJS();" % div
f.write('$(function() {\n %s\n});\n' % video)
print >> sys.stderr, 'Created %s' % out
@sbp
Copy link
Author

sbp commented Dec 27, 2011

Then this should work:

<script src="jquery.js"></script>
<script src="video.combo.js"></script>

<video width="640" height="264" poster="example.png">
 <source src="example.mp4" type="video/mp4">
 <source src="example.ogv" type="video/ogg">
</video>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment