Mercurial > public > bravenewsurf
comparison bns_website/templates/videos/index.html @ 60:a0d3bc630ebd
For issue #8, create a videos application to randomize videos in the playlist.
This commit now adds a dependency to the Google Python GData library.
The admin enters a playlist URL in the admin. Then the admin uses an admin action to synchronize the playlist with YouTube. This reads the playlist title and retrieves the video list from YouTube. The view function reads all the playlist objects to get the complete list of videos, then shuffles them up. The template generates Javascript to create a YouTube player with the shuffled list.
A fixture is included for convenience and for the tests.
I also committed a test tool I wrote to prove out this idea in case it is useful for future enhancements or experimentation.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 19 Nov 2011 14:19:00 -0600 |
parents | |
children | 1d2473f4bcaa |
comparison
equal
deleted
inserted
replaced
59:f8858447adda | 60:a0d3bc630ebd |
---|---|
1 {% extends 'base.html' %} | |
2 {% load core_tags %} | |
3 {% block title %}Watch{% endblock %} | |
4 {% block content %} | |
5 {% navbar 'videos' %} | |
6 <h1>Watch</h1> | |
7 | |
8 {% if videos %} | |
9 <p> | |
10 Please enjoy this {{ videos|length }} video playlist of the bands that performed on the | |
11 <em>Brave New Surf</em> compilation. You can use the button that looks like a widescreen TV | |
12 at the bottom of the player to scroll through all the videos. | |
13 </p> | |
14 <div id="player"></div> | |
15 | |
16 <script> | |
17 var tag = document.createElement('script'); | |
18 tag.src = "http://www.youtube.com/player_api"; | |
19 var firstScriptTag = document.getElementsByTagName('script')[0]; | |
20 firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); | |
21 | |
22 var player; | |
23 function onYouTubePlayerAPIReady() { | |
24 player = new YT.Player('player', { | |
25 videoId: '{{ videos|first }}', | |
26 {% if playlist %} | |
27 playerVars: { playlist: [ | |
28 {% for video in videos|slice:"1:" %} | |
29 {% if not forloop.first %},{% endif %}'{{ video }}' | |
30 {% endfor %} ]}, | |
31 {% endif %} | |
32 width: '853', | |
33 height: '480' | |
34 }); | |
35 } | |
36 </script> | |
37 | |
38 {% else %} | |
39 <p>Videos of the bands are coming soon. Please check back later.</p> | |
40 {% endif %} | |
41 {% endblock %} |