Coder Social home page Coder Social logo

stickyplayer's Introduction

StickyPlayer

Low-profile JavaScript music player that accepts SoundCloud, YouTube, Dropbox and direct web links.

Location of files

  • Local demo example/index.html file.
  • All Compiled and minified files (JS & CSS) as well as image files are in the dist/ folder.
  • Source script files are in the src/ folder and source image files are in the assets/ folder.

Build

To compile StickyPlayer by yourself, make sure you have Node.js, Grunt.js, Ruby and Sass installed. Then:

  1. Clone the repository

git clone https://github.com/jpodpro/stickyplayer.git

  1. Install Node dependencies

cd stickyplayer && npm install

  1. Run grunt to generate the JS files in the dist folder

grunt

Optionally:

  • Run grunt watch to automatically rebuild files when you change files in src/ or assets/.

Dependencies

Usage

  1. Include Dependencies
<!-- CrossPlayer -->
<script src="https://cdn.rawgit.com/jpodpro/crossplayer/master/dist/crossplayer.js"></script>

<!-- jQuery -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>

<!-- Bootstrap -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
  1. Include StickyPlayer JS and CSS files
<script src="stickyplayer.min.js"></script>
<link href="stickyplayer.min.css" rel="stylesheet">
  1. Create a DOM element for the player with unique ID:
<div id="unique-id"></div>
  1. Init StickyPlayer with required options (see options section below for more info). Make sure to initialize this script after the DOM has been rendered. Either place the init call before the </body> tag or use jQuery(document).ready() to init the player when the page has loaded.
var player = new StickyPlayer( {
    playerId: 'unique-id',
    observeElementId: 'observe',
    playButtonClass: 'sp-play-button'
} );
  1. Create links with specific attributes. They will automatically launch in the player. See "Play Button Schema" for more info.
<a class="sp-play-button" stream-link="https://www.youtube.com/watch?v=23idtAQna00" title="JPOD - BlissCoast vol6: Cape & Kalimba" artwork="http://jpodtbc.com/wp-content/uploads/2016/09/JPOD-BlissCoast-6-Cape-Kalimba2-300x300.jpg">Play</a>

Options

  • playerId the ID of the player DOM element. REQUIRED.
  • observeElementId the ID of the element to watch for DOM changes. This allows the player to function in an SPA by watching a container element for changes. As long as a child element has the required attributes it will automatically register itself to launch in the player. REQUIRED.
  • playButtonClass the class name to use for a play button. REQUIRED.
  • scClientId SoundCloud client ID required to use the HTTP API. When not provided the player uses the Widget API.

Play Button Schema

Any DOM element can be a player button as long as it contains four required attributes:

  1. Play button class, as specified in options.

  2. stream-link attribute which contains the URL to be streamed.

  3. title the title of the track to display in the player.

  4. artwork a link to the artwork to display in the player. Note: YouTube links don't use this as it shows the video in place of the artwork.

iOS Limitations

Apple requires direct user interaction for playing media files on iOS. That means that when using players within iFrames they cannot be programatically started. Additional user interaction is required. StickyPlayer uses CrossPlayer, which uses iFrames for the SoundCloud Widget player and the YouTube player. When loading a URL in this scenario the player will occupy the full size of its container (ideally full-screen) and display a message asking for additional user interaction. When playing commences the player resumes its low-profile position.

License

MIT

stickyplayer's People

Contributors

jpodpro avatar

Stargazers

 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.