I am using web2py to play user's uploaded video file encoding with
different encoding params.Only the original uploaded video is in db and it
can be accessed and played using code below:
<script type="text/javascript">
var flashvars = {};
flashvars.myurl = "{{=URL('download',
args=video.file)}}";
flashvars.width = {{=video.width}};
flashvars.height = {{=video.height}};
flashvars.widthshift = {{=video.widthshift}};
flashvars.method = "{{=video.method}}";
var params = {};
params.play = "false";
params.loop = "false";
params.menu = "false";
params.quality = "best";
params.scale = "showall";
params.wmode = "window";
params.swliveconnect = "true";
params.allowfullscreen = "true";
params.allowscriptaccess = "always";
params.allownetworking = "all";
var attributes = {};
attributes.id = "container";
swfobject.embedSWF("{{=URL(c='static',f='videoPlayer/videoPlay.swf')}}","myAlternativeContent",
{{=video.width}}, {{=video.height}}, "9.0.0", false, flashvars, params,
attributes);
</script>
<div id="myAlternativeContent">
<a href="http://www.adobe.com/go/getflashplayer">
<img
src="http://www.adobe.com/images/shared/download_buttons/
get_flash_player.gif" alt="Get Adobe Flash player"
/>
</a>
</div>
In the code flashvars.myurl = "{{=URL('download', args=video.file)}}"; the
controller download is below:
def download():
return response.download(request, db)
It works to play the uploaded video.The problem is the converted video
files using ffmpeg with other params is not in db, so I can't access these
videos via response.download.
I tried two methods:
1.Set flashvars.file="{{=URL(r=request,c='static',f='test.flv')}}",but the
flash player didn't play the video but the browser automatically popup a
file download window.
2.Set flashvars.myurl="{{=URL('show_video')}}"
in controller:
def show_video():
response.headers['Content-Type'] = "application/octet-stream"
response.headers['Content-Disposition'] = 'filename=test.flv'
return
response.stream(open('/data/python_website/web2py/applications/encodeupload/uploads/test.flv','rb'),chunk_size=4096)
It still popup a download window rather than play it.
Neither of them works. So how to play a video file without
response.download?