Skip to content

Instantly share code, notes, and snippets.

@furenku
Created September 17, 2020 18:55
Show Gist options
  • Select an option

  • Save furenku/128bacc8b80fb147260945b6e66bb3e6 to your computer and use it in GitHub Desktop.

Select an option

Save furenku/128bacc8b80fb147260945b6e66bb3e6 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.1.9/p5.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.1.9/addons/p5.sound.min.js"></script>
<script src="yuxtaposicion.js"></script>
</body>
</html>
let archivo = "videos/vd1.mp4"
let max = 10
let videos = []
let videosMostrar = []
function preload() {
for( let i = 0; i < max; i++ ) {
let video = createVideo( archivo )
videos.push( video )
video.hide()
}
videosMostrar.push( videos[0] )
videos[0].loop()
}
function setup() {
createCanvas( 1000, 600 )
}
function keyTyped() {
if( key == "o" ) {
if( videosMostrar.length < max ) {
let proximo = videos[ videosMostrar.length ]
proximo.time( random() * proximo.duration() - 2 )
videosMostrar.push( proximo )
proximo.loop()
}
}
}
function draw() {
for( let i in videosMostrar ) {
let video = videosMostrar[i]
let ancho = width / videosMostrar.length
image( video, i * ancho, 0, ancho, ancho )
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment