mirror of
https://github.com/captbaritone/webamp.git
synced 2026-01-23 02:15:01 +00:00
Add example showing multiple tracks
This commit is contained in:
parent
3c15b7f044
commit
0f431d9e05
3 changed files with 77 additions and 0 deletions
13
examples/multipleTracks/README.md
Normal file
13
examples/multipleTracks/README.md
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
# Multiple Tracks Example
|
||||
|
||||
An example of setting up Webamp with multiple audio tracks.
|
||||
|
||||
This example fetches the Webamp bundle from a free CDN, and fetches the audio file and skin from a free CDN as well.
|
||||
|
||||
You should be able to open this local html file in your browser and see Webamp working.
|
||||
|
||||
```
|
||||
$ git clone git@github.com:captbaritone/webamp.git
|
||||
$ cd webamp
|
||||
$ open examples/multipleSkins/index.html
|
||||
```
|
||||
62
examples/multipleTracks/index.html
Executable file
62
examples/multipleTracks/index.html
Executable file
|
|
@ -0,0 +1,62 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="app" style="height: 100vh">
|
||||
<!-- Webamp will attempt to center itself within this div -->
|
||||
</div>
|
||||
<script src="https://unpkg.com/webamp@1.4.2/built/webamp.bundle.min.js"></script>
|
||||
<script>
|
||||
const Webamp = window.Webamp;
|
||||
const webamp = new Webamp({
|
||||
/**
|
||||
* Here we list three tracks. Note that the `metaData` fields and
|
||||
* duration are required to populate the playlist. If any of those
|
||||
* fields are omitted, Webamp will download at least part of each file
|
||||
* on initial page load in order to determine the missing information.
|
||||
*/
|
||||
initialTracks: [
|
||||
{
|
||||
metaData: {
|
||||
artist: "DJ Mike Llama",
|
||||
title: "Llama Whippin' Intro",
|
||||
},
|
||||
// NOTE: Your audio file must be served from the same domain as your HTML
|
||||
// file, or served with permissive CORS HTTP headers:
|
||||
// https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
|
||||
url: "https://cdn.jsdelivr.net/gh/captbaritone/webamp@43434d82cfe0e37286dbbe0666072dc3190a83bc/mp3/llama-2.91.mp3",
|
||||
duration: 5.322286,
|
||||
},
|
||||
{
|
||||
metaData: {
|
||||
title: "Heroines",
|
||||
artist: "Diablo Swing Orchestra",
|
||||
},
|
||||
// NOTE: Your audio file must be served from the same domain as your HTML
|
||||
// file, or served with permissive CORS HTTP headers:
|
||||
// https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
|
||||
url: "https://raw.githubusercontent.com/captbaritone/webamp-music/4b556fbf/Diablo_Swing_Orchestra_-_01_-_Heroines.mp3",
|
||||
duration: 322.612245,
|
||||
},
|
||||
{
|
||||
metaData: {
|
||||
title: "We Are Going To Eclecfunk Your Ass",
|
||||
artist: "Eclectek",
|
||||
},
|
||||
// NOTE: Your audio file must be served from the same domain as your HTML
|
||||
// file, or served with permissive CORS HTTP headers:
|
||||
// https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
|
||||
url: "https://raw.githubusercontent.com/captbaritone/webamp-music/4b556fbf/Eclectek_-_02_-_We_Are_Going_To_Eclecfunk_Your_Ass.mp3",
|
||||
duration: 190.093061,
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
// Returns a promise indicating when it's done loading.
|
||||
webamp.renderWhenReady(document.getElementById("app"));
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -3,6 +3,8 @@
|
|||
This directory contains a number of examples of how to add Webamp to a project.
|
||||
|
||||
- [Minimal](./minimal) Stick Webamp in a `<script>` tag, and add a few lines of JavaScript to get Webamp on your page.
|
||||
- [Multiple Tracks](./multipleTracks) An example of setting up Webamp with multiple audio tracks.
|
||||
- [Multiple Skins](./multipleSkins) An example of setting up Webamp with multiple skins.
|
||||
- [Webpack](./webpack) Install Webamp via NPM and bundle it in a Webpack bundle.
|
||||
- [Webpack Lazyload](./webpackLazyLoad) **In progress**
|
||||
- [Minimal Milkdrop](./minimalMilkdrop) **In progress**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue