Demos for music player and music playlist functional.
This commit is contained in:
81
tutorials/MusicPlayer.html
Normal file
81
tutorials/MusicPlayer.html
Normal file
@@ -0,0 +1,81 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<link rel="stylesheet" href="./assets/css/prism.css" />
|
||||
<script src="./assets/js/prism.js" defer></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<script src="./assets/js/audioshowkit.js"></script>
|
||||
<div>
|
||||
<h1>Creating a Music Player</h1>
|
||||
<p>One of the most basic principles behind AudioShowKit is the {@link module:player/MusicPlayer}. The song player acts as an easy way for developers to set up a list of songs with simple generated controls while exposing more complex events if needed.</p>
|
||||
</div>
|
||||
<div>
|
||||
<h2>Instantiating a Music Player</h2>
|
||||
<p>Instantiating a music player requires a {@link module:player/MusicPlaylist}. See the [MusicPlaylist tutorial]{@tutorial MusicPlaylist} for information on how to get one of those! Once you have one, you can proceed with instantiating a Music Player.</p>
|
||||
<pre><code class="language-js">
|
||||
const ask = window.audioshowkit; // Get a reference to the audioshowkit stuff.
|
||||
const playlist = previousPlaylist; // We are assuming you have a playlist ready.
|
||||
const player = new ask.player.MusicPlayer(playlist) // Creates a new music player with the playlist.
|
||||
</code></pre>
|
||||
</div>
|
||||
<div>
|
||||
<h2>Display a Play Button</h2>
|
||||
<p>We need some user interactive element to start playing music. You can set this up yourself, or use a generated one by us! We'll show you how to do the latter, but feel free to read the documentation on all the methods available that can be used in event listeners to see how to do the former.</p>
|
||||
<pre><code class="language-js">
|
||||
// Still using the same context from the instantiation example...
|
||||
const playElement = player.generatePlayElement();
|
||||
document.getElementById("musicplayer-playbtn-demo").appendChild(playElement); // Assuming this element exists.
|
||||
</code></pre>
|
||||
<h3>The play button</h3>
|
||||
<p>Go ahead and hit the play button!</p>
|
||||
<div class="result">
|
||||
<div id="musicplayer-playbtn-demo">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div>
|
||||
<h2>Similarly, Next and Previous Buttons</h2>
|
||||
<p>We can also traverse the playlist by the player via a previous and next button. These buttons can be generated as well as programmed.</p>
|
||||
<pre><code class="language-js">
|
||||
// Still using the same context from the instantiation example...
|
||||
const nextElement = player.generateNextElement();
|
||||
document.getElementById("musicplayer-nextbtn-demo").appendChild(nextElement);
|
||||
|
||||
const prevElem = player.generatePreviousElement();
|
||||
document.getElementById("musicplayer-prevbtn-demo").appendChild(prevElem);
|
||||
</code></pre>
|
||||
<h3>The next button</h3>
|
||||
<div class="result">
|
||||
<div id="musicplayer-nextbtn-demo">
|
||||
</div>
|
||||
</div>
|
||||
<h3>The previous button</h3>
|
||||
<div class="result">
|
||||
<div id="musicplayer-prevbtn-demo">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
const ask = window.audioshowkit;
|
||||
const playlist = new ask.player.MusicPlaylist("Awesome Music");
|
||||
|
||||
playlist.add("https://res.sys.reslate.xyz/dl/audio/moments.mp3", "Moments", "Lost Identities x Robbie Rosen");
|
||||
playlist.add("https://res.sys.reslate.xyz/dl/audio/XXI.mp3", "XXI", "QR");
|
||||
|
||||
const player = new ask.player.MusicPlayer(playlist);
|
||||
const playElem = player.generatePlayElement();
|
||||
document.getElementById("musicplayer-playbtn-demo").appendChild(playElem);
|
||||
|
||||
const nextElem = player.generateNextElement();
|
||||
document.getElementById("musicplayer-nextbtn-demo").appendChild(nextElem);
|
||||
|
||||
const prevElem = player.generatePreviousElement();
|
||||
document.getElementById("musicplayer-prevbtn-demo").appendChild(prevElem);
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
79
tutorials/MusicPlaylist.html
Normal file
79
tutorials/MusicPlaylist.html
Normal file
@@ -0,0 +1,79 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<link rel="stylesheet" href="./assets/css/prism.css" />
|
||||
<script src="./assets/js/prism.js" defer></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<script src="./assets/js/audioshowkit.js"></script>
|
||||
<div>
|
||||
<h1>Creating a Music Playlist</h1>
|
||||
<p>
|
||||
A music playlist is a list of {@link module:player/Music} which maintains metadata about the playlist, such as the length, and the name of the playlist. It also keeps track of an index for a position in the playlist.
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<h2>Instantiation</h2>
|
||||
<pre><code class="language-js">
|
||||
// Get the entry point to all of AudioShowKit's glory.
|
||||
const ask = window.audioshowkit;
|
||||
|
||||
// The only parameter is the name of the playlist.
|
||||
const playlist = new ask.player.MusicPlaylist("Awesome Music");
|
||||
</code></pre>
|
||||
</div>
|
||||
<div>
|
||||
<h2>Adding Music</h2>
|
||||
<p>A music playlist is no good if it doesn't have music. Lets add some.</p>
|
||||
<pre><code class="language-js">
|
||||
// Still using the same context from the instantiation example...
|
||||
|
||||
playlist.add("/assets/audio/moments.mp3", "Moments", "Lost Identities x Robbie Rosen"); // It's that easy.
|
||||
playlist.add("/assets/audio/XXI.mp3", "XXI", "QR"); // Let's add another one.
|
||||
</code></pre>
|
||||
|
||||
<p>If for whatever reason, you decided to instantiate your own {@link module:player/Music}, that's okay too!</p>
|
||||
<pre><code class="language-js">
|
||||
// Still using the same context from the instantiation example...
|
||||
|
||||
// Either instantiate, or otherwise have this Music object.
|
||||
const pathetiqueMusic = new ask.player.Music("/assets/audio/pathetique.mp3", "Sonata No. 8", "Beethoven");
|
||||
playlist.addExisting(pathetiqueMusic); // Wow, a special function!
|
||||
</code></pre>
|
||||
</div>
|
||||
<div>
|
||||
<h2>Display</h2>
|
||||
<p>In the case you want to show the playlist without coding your own display, we provide a simple generator for you!</p>
|
||||
<pre><code class="language-js">
|
||||
// Still using the same context from the instantiation example...
|
||||
|
||||
const playlistElem = playlist.generatePlaylistElement(); // Returns an HTMLElement!
|
||||
|
||||
// Assuming we do have an acceptable element that can take a child element.
|
||||
document.getElementById("musicplaylist-demo").appendChild(playlistElem);
|
||||
</code></pre>
|
||||
<div class="result">
|
||||
<h3>Result</h3>
|
||||
<div id="musicplaylist-demo">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const ask = window.audioshowkit;
|
||||
const playlist = new ask.player.MusicPlaylist("Awesome Music");
|
||||
|
||||
playlist.add("/assets/audio/moments.mp3", "Moments", "Lost Identities x Robbie Rosen"); // It's that easy.
|
||||
playlist.add("/assets/audio/XXI.mp3", "XXI", "QR"); // Let's add another one.
|
||||
|
||||
const pathetiqueMusic = new ask.player.Music("/assets/audio/pathetique.mp3", "Sonata No. 8", "Beethoven");
|
||||
playlist.addExisting(pathetiqueMusic);
|
||||
|
||||
const playlistElem = playlist.generatePlaylistElement();
|
||||
document.getElementById("musicplaylist-demo").appendChild(playlistElem);
|
||||
</script>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
@@ -1,18 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Creating a Song Player</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div>
|
||||
<h1>Creating a Song Player</h1>
|
||||
<p>One of the most basic principles behind AudioShowKit is the {@link module:player/SongPlayer}. The song player acts as an easy way for developers to set up a list of songs and play them back with simple controls.</p>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
@@ -1,14 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
BIN
tutorials/assets/audio/pathetique.mp3
Normal file
BIN
tutorials/assets/audio/pathetique.mp3
Normal file
Binary file not shown.
3
tutorials/assets/css/prism.css
Normal file
3
tutorials/assets/css/prism.css
Normal file
@@ -0,0 +1,3 @@
|
||||
/* PrismJS 1.28.0
|
||||
https://prismjs.com/download.html#themes=prism-tomorrow&languages=markup+css+clike+javascript */
|
||||
code[class*=language-],pre[class*=language-]{color:#ccc;background:0 0;font-family:Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace;font-size:1em;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none}pre[class*=language-]{padding:1em;margin:.5em 0;overflow:auto}:not(pre)>code[class*=language-],pre[class*=language-]{background:#2d2d2d}:not(pre)>code[class*=language-]{padding:.1em;border-radius:.3em;white-space:normal}.token.block-comment,.token.cdata,.token.comment,.token.doctype,.token.prolog{color:#999}.token.punctuation{color:#ccc}.token.attr-name,.token.deleted,.token.namespace,.token.tag{color:#e2777a}.token.function-name{color:#6196cc}.token.boolean,.token.function,.token.number{color:#f08d49}.token.class-name,.token.constant,.token.property,.token.symbol{color:#f8c555}.token.atrule,.token.builtin,.token.important,.token.keyword,.token.selector{color:#cc99cd}.token.attr-value,.token.char,.token.regex,.token.string,.token.variable{color:#7ec699}.token.entity,.token.operator,.token.url{color:#67cdcc}.token.bold,.token.important{font-weight:700}.token.italic{font-style:italic}.token.entity{cursor:help}.token.inserted{color:green}
|
340
tutorials/assets/js/audioshowkit.js
Normal file
340
tutorials/assets/js/audioshowkit.js
Normal file
File diff suppressed because one or more lines are too long
7
tutorials/assets/js/prism.js
Normal file
7
tutorials/assets/js/prism.js
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user