Giter Club home page Giter Club logo

audio-player's Introduction

#Audio Player ##What? A simple HTML5 audio player plugin for jQuery, supporting a playlist.

##Why? Helping my brother create a music blog, I was struck by the lack of decent, simple audio players that supported a playlist. After a cursory internet search, I decided it'd probably be more fun (for me, not my brother) to code my own.

##How? Like this!

<html>
<head>
    <!-- First the CSS -->
    <link rel="stylesheet" href="css/player.css">

    <!-- jQuery here! -->

    <!-- And now the magic sauce! -->
    <script type="text/javascript" src="js/player.js"></script>
    <script type="text/javascript">
      $(document).ready(function(){
          $("#my-player").audioPlayer({
            tracks: [
              {
                name: "Track One",
                artist: "Professor Famous",
                src: "mp3/professor_famous-track_one.mp3"
              },
              {
                name: "Track Two",
                artist: "Professor Famous",
                src: "mp3/professor_famous-track_two.mp3"
              }
            ]
          });
        });
    </script>
  </head>
  <body>
    <div id="my-player">
    </div>
  </body>
</html>

##What then? You'll get something that looks a bit like this!

Default View

##Does it work? Of course! Well, mostly. There are probably a few bugs - feel free to report them or squish them.

##Can I customise this monstrosity? You can (just modify the CSS), but for now you can't do much about the HTML5 audio element's appearance using this plugin.

What you can do, is specify the location of your own next / previous buttons, and the location of the playlist container. To do this, you simply pass those elements into the initial function call, like so:

$("#my-player").audioPlayer({
  nextButton: $(".my-next-button"),
  prevButton: $(".my-prev-button"),
  listContainer: $(".my-list-container"),
  tracks: [
    {
      name: "Track One",
      artist: "Professor Famous",
      src: "mp3/professor_famous-track_one.mp3"
    },
    {
      name: "Track Two",
      artist: "Professor Famous",
      src: "mp3/professor_famous-track_two.mp3"
    }
  ]
});

You can then style those elements however you like.

##What's next? Things I'd like to add (in no particular order):

  1. Ability to add / remove / swap tracks on the fly.
  2. Ability to specify artwork for tracks (although simplicity is preferable to feature overload)
  3. Support for custom player controls (play / pause / scrubber / timer etc)

##Anything else? You can pass the following options into the plugin (defaults shown):

$("#my-player").audioPlayer({
  autoPlay: false, //Whether to start playing immediately

  tracks: [], //An array of tracks of the form { name: "", artist: "", src: ""}

  controls: true, //Whether to display the HTML Audio element controls

  listContainer: null, //The jQuery wrapped element in which to display the playlist

  nextButton: null, //The jQuery wrapped element to use as the Next button

  prevButton: null //The jQuery wrapped element to use as the Play button
});

audio-player's People

Contributors

tomfromthepool avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.