Closed
Description
Increasing access
Make this function more useful, which could have accessibility implications
Most appropriate sub-area of p5.js?
- AccessibilityColorCore/Environment/RenderingDataDOMEventsImageIOMathTypographyUtilitiesWebGLBuild processUnit testingInternationalizationFriendly errorsOther (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
})
)
}
}
Activity
ffd8 commentedon Jan 15, 2025
Quick followup, of course this can be done without the callback by first preloading it – but a small modification would then require less code.
dhruvinjs commentedon Jan 15, 2025
Hey So, am new here would love to help you on fixing this issue here?
subCode321 commentedon Feb 28, 2025
@ffd8 , I've put our a PR to make the changes
ksen0 commentedon Jun 4, 2025
@davepagurek I see the same pattern in 2.0 on p5.MediaElement:1324 - should I make the matching PR there?
davepagurek commentedon Jun 4, 2025
That would be great, thanks!