Giter Site home page Giter Site logo

benjipott / videojs-soundcloud Goto Github PK

View Code? Open in Web Editor NEW

This project forked from acconut/videojs-soundcloud

0.0 2.0 0.0 158 KB

A videojs plugin to support soundcloud links

License: GNU General Public License v3.0

CoffeeScript 8.03% JavaScript 91.49% HTML 0.49%

videojs-soundcloud's Introduction

videojs-soundcloud

Build Status

A videojs/video-js plugin to support soundcloud track links e.g https://soundcloud.com/vaughan-1-1/this-is-what-crazy-looks-like

How to use (with coffeescript)

The project uses coffeescript, which is a language that compiles into javascript locally or in the browser using <script type="text/coffeescript"> as described here.

<head>
  <!-- Mandatory videojs include! -->
  <script src="http://vjs.zencdn.net/4.2.2/video.js"></script>
  <link href="http://vjs.zencdn.net/4.2.2/video-js.css" rel="stylesheet">
  <script type="text/javascript" src="http://coffeescript.org/extras/coffee-script.js"></script>
  <script type="text/coffeescript" src="src/media.soundcloud.coffee"></script>
</head>
<body>
  <video
    id="myStuff"
    class="video-js vjs-default-skin"
    controls
    preload="auto"
    width="100%"
    height="360"
    data-setup=''
    ></video>
    <!--
      Dynamic include
      coffeescript is compiled in the onload cycle
    -->
    <script type="text/coffeescript">
      videojs "myStuff", {
          "techOrder": ["soundcloud"]
          "source": ["https://soundcloud.com/vaughan-1-1/this-is-what-crazy-looks-like"]
          }, ->
    </script>
</body>

More information is in the example below.

Example

JsFiddle with a single soundcloud source

Or run npm install && grunt compile and open the generated example in example/index.html

Developing

  • npm install to prepare the environment
  • npm test to run the tests once (Karma with Jasmine)
  • npm run karma to run tests continuously once a file is changed
  • grunt after npm install to prepare running the example at example/index.html
  • grunt watch to continuously compile coffee and jade, and run livereload for the example you can run this alongside npm run karma if you wish

How it works

We create an iframe (with a soundcloud-embed URL) in the player-element and, using the soundcloud [Widget API](http://developers.soundcloud.com/docs/api/html5-widget] we initialize a widget that will give us the control methods, getters and setters we need.
Once the iframe is created it is hidden!

More in detail notes

Getters

Since communication between the parent page and the widget's iframe is implemented through window.postMessage, it's not possible to return the value synchronously. Because of this, every getter method accepts a callback function as a parameter which, when called, will be given the return value of the getter method.

Due to this we have quite a few state variables when using the widget API.

Documentation

Is generated with Codo and hosted on coffeedoc.info. Props to them :)

videojs-soundcloud's People

Contributors

benjipott avatar

Watchers

James Cloos avatar  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.