File tree 1 file changed +37
-3
lines changed
1 file changed +37
-3
lines changed Original file line number Diff line number Diff line change 1818
1818
1819
1819
1820
1820
/**
1821
- * Play an HTML5 media element.
1821
+ * Play an HTML5 media element.
1822
1822
*
1823
- * @method play
1824
- * @return {Object|p5.Element }
1823
+ * @method play
1824
+ * @return {Object|p5.Element }
1825
+ * @example
1826
+ * <div><code>
1827
+ * var ele;
1828
+ *
1829
+ * function setup() {
1830
+ * //p5.MediaElement objects are usually created
1831
+ * //by calling the createAudio(), createVideo(),
1832
+ * //and createCapture() functions.
1833
+ *
1834
+ * //In this example we create
1835
+ * //a new p5.MediaElement via createAudio().
1836
+ * ele = createAudio('assets/beat.mp3');
1837
+ *
1838
+ * background(250);
1839
+ * textAlign(CENTER);
1840
+ * text("Click to Play!", width/2, height/2);
1841
+ * }
1842
+ *
1843
+ * function mouseClicked() {
1844
+ * //here we test if the mouse is over the
1845
+ * //canvas element when it's clicked
1846
+ * if(mouseX >= 0 && mouseX <= width &&
1847
+ * mouseY >= 0 && mouseY <= height) {
1848
+ *
1849
+ * //Here we call the play() function on
1850
+ * //the p5.MediaElement we created above.
1851
+ * //This will start the audio sample.
1852
+ * ele.play();
1853
+ *
1854
+ * background(200);
1855
+ * text("You clicked Play!", width/2, height/2);
1856
+ * }
1857
+ * }
1858
+ * </code></div>
1825
1859
*/
1826
1860
p5 . MediaElement . prototype . play = function ( ) {
1827
1861
if ( this . elt . currentTime === this . elt . duration ) {
You can’t perform that action at this time.
0 commit comments