1 from django.http import HttpResponse
2 from django.template import RequestContext
3 from django.shortcuts import render_to_response
4 from madrona.screencasts.models import Screencast, YoutubeScreencast
5
6 from django.conf import settings
7
9 return render_to_response(screencasts_template, context_instance=RequestContext(request, {'MEDIA_URL':settings.MEDIA_URL, 'screencast_list':Screencast.objects.all()}))
10
11 -def showVideo(request, urlname, demo_template='demo_video.html'):
12 try:
13 screencast = Screencast.objects.get(urlname=urlname)
14 except:
15 return HttpResponse("Screencast " + urlname + " does not exist.", status=404)
16
17 return render_to_response(demo_template, {'videoplayer':settings.VIDEO_PLAYER, 'screencast':screencast}, context_instance=RequestContext(request))
18
19
21 try:
22 screencast = Screencast.objects.get(pk=pk)
23 except:
24 return HttpResponse("Screencast does not exist.", status=404)
25
26 if not settings.VIDEO_PLAYER:
27 return HttpResponse("Server error - VIDEO_PLAYER is not defined.", status=500)
28
29 import os
30 player_path = settings.MEDIA_ROOT + "../" + settings.VIDEO_PLAYER
31 if not os.path.exists(player_path):
32 return HttpResponse("Server error - VIDEO_PLAYER does not exist <br/> should live at %s" % settings.VIDEO_PLAYER, status=500)
33
34 return render_to_response(demo_template, {'videoplayer':settings.VIDEO_PLAYER, 'screencast':screencast}, context_instance=RequestContext(request))
35
37 try:
38 screencast = YoutubeScreencast.objects.get(pk=pk)
39 except:
40 return HttpResponse("Screencast does not exist.", status=404)
41
42 return render_to_response('youtube_video.html', {'screencast':screencast}, context_instance=RequestContext(request))
43