videoJs
参考资料
video.html
{{context.title}}
欢迎访问樱花视频网站!
上一页
{% if context.page_list %}
{% for pg in context.page_list %}
{{pg}}
{% endfor %}
{% endif %}
下一页
{% if context.data %}
{% for li in context.data %}
名前:{{li.title}}
メール:{{li.address}}
時間:{{context.time | date:"H:i:s"}}
id:{{li.id}}
{% empty %}
no!
{% endfor %}
{% endif %}
{%load mydigit%}
当前页数:{{context.current_page}}
总页数:{{context.pages }}
总数量:{{context.num | mydigit:4}}
时间:{{context.time | date:"Y-m-d H:i:s" }}
views.py
def video_pages(request,page=1):
page=int(page)
set_video_num=15
template=loader.get_template("video.html")
all_list=Video.objects.all()#读取数据库信息
if (page<=0):
url="http://127.0.0.1:8000/video/"
return HttpResponseRedirect(url)
if(len(all_list)<(page-1)*set_video_num+1):
url="http://127.0.0.1:8000/video/"
return HttpResponseRedirect(url)
data_list=[]
for i in range((page-1)*set_video_num,page*set_video_num):
data_list.append(all_list[i])
if(len(data_list)%set_video_num==0):
pages=len(all_list)/set_video_num
else:
pages=len(all_list)/set_video_num + 1
context={"title":"Player!","time":datetime.datetime.now(),"data":data_list,"num":len(all_list),"pages":pages,"current_page":page,"page_list":list(range(1,pages+1))}
request_context = RequestContext(request, context)
request_context.push(locals())
html=template.render(context=locals(), request=request)
return HttpResponse(html)
网站预览示例
数据库信息预览
访问网址:127.0.0.1:8000/video/1
urlpatterns = [
url(r"^video/(?P\d+)/$", views.video_pages),
]
问题:
var player = videojs('my-video’, { "poster": "", "controls": "false" , }, function())
videojs不能被多次实例化,视频显示失败(添加模板变量后缀)
var player = videojs('my-video-{{li.id}}', { "poster": "", "controls": "false" , }, function())
仍旧会有问题(警告),但功能正常