Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edit docs for dom objects #6552

Merged
merged 6 commits into from
Nov 17, 2023
Merged

Conversation

nickmcintyre
Copy link
Member

@nickmcintyre nickmcintyre commented Nov 11, 2023

Addresses #6511

Changes:

I edited the inline docs for objects in src/dom/dom.js including:

  • p5.MediaElement
  • p5.File

@dkessner, @MsQCompSci, @davepagurek, @limzykenneth, @Qianqianye, @SarveshLimaye, @SoundaryaKoutharapu, @ramya202000, @BamaCharanChhandogi, @Obi-Engine10, @MarceloGoncalves, @hiddenenigma I'd love to incorporate any feedback you may have! Here's a staging version of the edits in this pull request.

PR Checklist

  • npm run lint passes
  • [Inline documentation] is included / updated

@MsQCompSci
Copy link

  • Comments describing what code does in examples will be helpful for new users for .change()
  • New users would benefit from examples (with descriptive comments) for p5.File
    Great work!

@nickmcintyre
Copy link
Member Author

Great suggestions @MsQCompSci – just added examples for p5.File.

I just double-checked and it turns out I edited p5.Element.changed() and p5.Element.input() as part of #6534. I accidentally lumped them in with the top-level DOM functions because they're in a different part of the file.

@nickmcintyre
Copy link
Member Author

@davepagurek @limzykenneth @Qianqianye if these changes look good to you, please go ahead and merge them.

src/dom/dom.js Outdated
* // Create a p5.MediaElement using createAudio().
* beat = createAudio('assets/beat.mp3');
* // Play the beat in a loop.
* beat.loop();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this one might not work when navigating directly to the page since it's trying to autoplay sound. Maybe this could be a muted video so you can see it play immediately? Or maybe double clicking starts the loop instead of stops it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't tried in awhile but last I remember double click can be a bit flaky on touch screens (they will zoom instead) so might want to consider just using single click overall.

src/dom/dom.js Outdated
* // Create a p5.MediaElement using createAudio().
* beat = createAudio('assets/beat.mp3');
* // Play the beat in a loop.
* beat.loop();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one too I think

src/dom/dom.js Outdated
* // Create a p5.MediaElement using createAudio().
* dragon = createAudio('assets/lucky_dragons.mp3');
* // Play the audio in a loop.
* dragon.loop();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one too

src/dom/dom.js Outdated
* textAlign(CENTER);
* text('start at beginning', width / 2, height / 2);
* textWrap(CHAR);
* text('Double-click to goto 2 seconds', 10, 10);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might need to adjust the coordinates for the text:
image

src/dom/dom.js Outdated
*
* // Create a p5.MediaElement using createAudio();
* let beat = createAudio('assets/beat.mp3');
* beat.autoplay(true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might need it to be muted for this to work reliably. Maybe doing video instead of audio for a lot of these examples would let us keep the autoplay behaviour while muted?

@nickmcintyre
Copy link
Member Author

Great suggestions @davepagurek @limzykenneth. I tried to work around most of these issues using media.showControls() and mousePressed().

Copy link
Contributor

@davepagurek davepagurek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks for your patience on all the fixes!

src/dom/dom.js Outdated
* dragon.showControls();
*
* // Jump to a random starting time.
* let d = dragon.duration();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh looks like the tests are failing on this one. It seems like duration() is NaN on first load. You might have to do this code block in the loaded callback for createAudio?

Copy link
Member Author

@nickmcintyre nickmcintyre Nov 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Starting at a random time isn't essential, so now it just jumps to 2 seconds. Feels more focused.

@davepagurek davepagurek merged commit 210bbe5 into processing:main Nov 17, 2023
2 checks passed
@nickmcintyre nickmcintyre deleted the sod-dom-objects branch May 6, 2024 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

4 participants