Created
January 11, 2018 08:36
-
-
Save t2psyto/d877d2d05180d82976f6ad1f8644e464 to your computer and use it in GitHub Desktop.
Brython video & canvas example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | |
<title>video & canvas example</title> | |
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/brython/3.4.0/brython.min.js"></script> | |
</head> | |
<body onload="brython()"> | |
<h1>Brython video & canvas example</h1> | |
<div id='main'></div> | |
<script type="text/python"> | |
import browser | |
from browser import html, document, window | |
aa = document['main'] | |
videotag = html.VIDEO(id='video', width='320', height='240', loop=True, controls=True) | |
aa.html = "" | |
aa <= videotag | |
aa <= " " | |
canvastag = html.CANVAS(id='canvas', width='320', height='240') | |
aa <= canvastag | |
video = document['video'] | |
video.src = "http://www.sample-videos.com/video/mp4/240/big_buck_bunny_240p_1mb.mp4" | |
#video.play() | |
#video.style.display = 'none'; | |
canvas = document['canvas'] | |
# 反転 | |
canvas.style.transform = 'rotateY(180deg)'; | |
context = canvas.getContext('2d'); | |
def OnDraw(): | |
context.drawImage(video, 0, 0, canvas.width, canvas.height); | |
window.requestAnimationFrame(OnDraw); | |
OnDraw() | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment