Skip to content

createVideo() callback could return instance of video #7468

Open
@ffd8

Description

Increasing access

Make this function more useful, which could have accessibility implications

Most appropriate sub-area of p5.js?

  • Accessibility
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • WebGL
  • Build process
  • Unit testing
  • Internationalization
  • Friendly errors
  • Other (specify if possible)

Feature enhancement details

Was just testing loading an array of createVideo(), in which each one should be muted, looped and hidden, however I learned that the callback function doesn't include the instance of media to directly affect, rather it expects a single global variable is used. Perhaps this could return as a param the media instance, so that one can directly mute, hide, loop that video once loaded?

let videos = [
	'path1.mov',
	'path2.mov',
	'path3.mov',
	'path4.mov',
	]
	
let videoPlayers = []

function setup() {
	createCanvas(windowWidth, windowHeight)
	
	for(let v of videos){
		videoPlayers.push(createVideo('data/videos/' + v, (vid) => {
			print(vid) // *** undefined, but ideal if that was returned media item
			videoPlayers[videoPlayers.length-1].volume(0) // only works once, too fast on next call
			videoPlayers[videoPlayers.length-1].loop() // only works once, too fast on next call
			videoPlayers[videoPlayers.length-1].hide() // only works once, too fast on next call
			})
		)
	}
}

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions