Giter Club home page Giter Club logo

playemjs's Introduction

Analytics

PlayemJS

PlayemJS is a front-end JavaScript component that manages a audio/video track queue and plays those tracks sequentially.

It can currently play tracks from the following streaming platforms:

  • Youtube
  • Soundcloud
  • Deezer
  • Bandcamp
  • Vimeo
  • Dailymotion
  • Jamendo
  • ... and MP3 files hosted online

Depending on the platform of each track, PlayemJS dynamically embeds the media in a HTML element, or through the Soundmanager2 audio player.

PlayemJS powers the music curation service Openwhyd.org (formerly whyd.com). That's the best demonstration of its capabilities.

Examples

1. Play just a Vimeo video

<div id="playem_video"></div>
<script src="playem.js"></script>
<script src="playem-vimeo.js"></script>
<script>
  const handlers = {};
  const config = {
      playerContainer: document.getElementById("playem_video"),
  };

  new VimeoPlayer(handlers, config)
    .play("98417189");
</script>

▶️ Watch it work live on Codepen

2. Play Vimeo and Youtube videos

Using a playlist, multiple players and Event logging.

<div id="playem_video"></div>
<script src="playem.js"></script>
<script src="playem-vimeo.js"></script>
<script src="playem-youtube.js"></script>
<script>
  YOUTUBE_API_KEY = "XxXxXxXxXxXxXxXxXxXxXxXxXxXxXx"; 

  const config = {
      playerContainer: document.getElementById("playem_video"),
  };

  // init playem and players
  var playem = new Playem();
  playem.addPlayer(VimeoPlayer, config);
  playem.addPlayer(YoutubePlayer, config);

  // play video tracks
  playem.addTrackByUrl("vimeo.com/50872925");
  playem.addTrackByUrl("youtube.com/watch?v=2m5K5jxME18");
  playem.play();
</script>

▶️ Watch it work live on Codepen

3. Play Video and Audio streams

Relies on soundmanager2.

<div id="playem_video"></div>
<script src="playem.js"></script>
<script src="playem-vimeo.js"></script>
<script src="playem-audiofile.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/soundmanager2/2.97a.20150601/script/soundmanager2-jsmin.js"></script>
<script>
  const config = {
      playerContainer: document.getElementById("playem_video"),
  };

  // init playem and players
  var playem = new Playem();
  playem.addPlayer(AudioFilePlayer, config);
  playem.addPlayer(VimeoPlayer, config);

  // init logging for player events
  playem.on("onTrackChange", (data) => console.log("play track " + data.trackId));
  playem.on("onError", (data) => console.error("error:", data));

  // create a playlist
  playem.addTrackByUrl("https://archive.org/download/JeremyJereskyDrumLoop/drumLoop.mp3");
  playem.addTrackByUrl("vimeo.com/50872925");

  // wait for soundmanager to be ready before playing tracks
  soundManager.setup({ onready: () => playem.play() });
  soundManager.beginDelayedInit();
</script>

▶️ Watch it work live on Codepen

Usage with npm

npm install playemjs

Then use it that way in your front-end code:

<div id="container"></div>
<script src="dist/playem-min.js"></script>
<script>
  // your app's API KEYS here
  window.SOUNDCLOUD_CLIENT_ID = "11f9999111b5555c22227777c3333fed"; // your api key
  window.DEEZER_APP_ID = 123456789;
  window.DEEZER_CHANNEL_URL = "http://mysite.com/deezer-channel.html";
  window.JAMENDO_CLIENT_ID = "f9ff9f0f";

  var playerParams = {
    playerId: "genericplayer",
    origin: window.location.host || window.location.hostname,
    playerContainer: document.getElementById("container")
  };

  window.makePlayem(null, playerParams, function onLoaded(playem){
    playem.on("onTrackChange", function(track){
      console.log("streaming track " + track.trackId + " from " + track.playerName);
    });
    playem.addTrackByUrl("https://www.youtube.com/watch?v=fuhHU_BZXSk");
    playem.addTrackByUrl("https://www.dailymotion.com/video/x25ohb");
    playem.play();
  });
</script>

React component

(Work in progress) Check out react-music-player.

Tests and further development

You can run tests from that page:

If they don't work from there, you can clone the project, and run them locally.

Any help in documenting/fixing/developing this project is welcome! :-)

playemjs's People

Contributors

adrienjoly avatar damienromito avatar dependabot[bot] avatar has12zen avatar mauricesvay avatar selbahc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

playemjs's Issues

use of APIs (and API keys) should be optional

After YouTube reduced Openwhyd's quota to their API, we realized that we were relying too much on Playem, which is also relying too much on YouTube's API.

This library should only care about embedding and playing content, not detecting and/or fetching metadata.

=> Proposal: move track detection and track metadata retrieval to a separate lib and/or to Openwhyd's bookmarklet, like we started to do in openwhyd/openwhyd#285.

generate new soundcloud API key ?

I received this email from soundcloud, this morning:

Hello,We are reaching out today as you are the registered owner of a SoundCloud application that has been inactive for over 3 months. We’re writing to inform you that as of June 8, 2023, we are revoking access to your application in order to make necessary changes to our platform. As a result you will be unable to access SoundCloud’s API and any apps that use our APIs will no longer work.We understand that this may be disappointing; however, we need to do this for two reasons:Recently, we haven’t been able to provide developers with the level of support that you deserve. That includes being able to help you when things go wrong and supporting you when you build amazing things.More pressingly, we haven’t been able to sustain the level of oversight needed to make sure bad actors aren’t abusing our API. As such, change is necessary in order to protect the artists and fans that use SoundCloud’s services.Rest assured, this is not the final state of our API program - just a temporary reset. We’re working hard to reopen the doors as soon as possible so that you can use our API in the future.We’ll be releasing updates over the coming months, so please keep an eye on our Developer Blog and Twitter for updates to come.Amid these changes, we value your feedback. If you have notes or ideas for our developer platform, please feel free to leave comments on the form.

Hello,

We are reaching out today as you are the registered owner of a SoundCloud application that has been inactive for over 3 months. We’re writing to inform you that as of June 8, 2023, we are revoking access to your application in order to make necessary changes to our platform. As a result you will be unable to access SoundCloud’s API and any apps that use our APIs will no longer work.

We understand that this may be disappointing; however, we need to do this for two reasons:
  • Recently, we haven’t been able to provide developers with the level of support that you deserve. That includes being able to help you when things go wrong and supporting you when you build amazing things.
  • More pressingly, we haven’t been able to sustain the level of oversight needed to make sure bad actors aren’t abusing our API. As such, change is necessary in order to protect the artists and fans that use SoundCloud’s services.
Rest assured, this is not the final state of our API program - just a temporary reset. We’re working hard to reopen the doors as soon as possible so that you can use our API in the future.

We’ll be releasing updates over the coming months, so please keep an eye on our Developer Blog and Twitter for updates to come.

Amid these changes, we value your feedback. If you have notes or ideas for our developer platform, please feel free to leave comments on the form.
SOUNDCLOUD Hello,

We are reaching out today as you are the registered owner of a SoundCloud application that has been inactive for over 3 months. We’re writing to inform you that as of June 8, 2023, we are revoking access to your application in order to make necessary changes to our platform. As a result you will be unable to access SoundCloud’s API and any apps that use our APIs will no longer work.

We understand that this may be disappointing; however, we need to do this for two reasons:
Recently, we haven’t been able to provide developers with the level of support that you deserve. That includes being able to help you when things go wrong and supporting you when you build amazing things.
More pressingly, we haven’t been able to sustain the level of oversight needed to make sure bad actors aren’t abusing our API. As such, change is necessary in order to protect the artists and fans that use SoundCloud’s services.
Rest assured, this is not the final state of our API program - just a temporary reset. We’re working hard to reopen the doors as soon as possible so that you can use our API in the future.

We’ll be releasing updates over the coming months, so please keep an eye on our Developer Blog and Twitter for updates to come.

Amid these changes, we value your feedback. If you have notes or ideas for our developer platform, please feel free to leave comments on the form.

Remove Flash/swfobject dependencies and mentions

PlayemJS is a web/js component to play a sequence of tracks from Youtube, Soundcloud, Bandcamp and several other streaming sources. It's the core of openwhyd.org's music web app.


Objectives

  • reduce footprint of the library / component, by removing the swfobject dependency and related code
  • prevent browser warnings like "this page uses a deprecated plug-in"
  • increase trust and interest towards playemjs, by being fully HTML5-compliant

Howto

In order to solve this issue, you are invited to fork this GitHub repository, makes changes to it, and then create a Pull Request so we can merge your changes back to this repository.

First, you may want to read about:

  • How to install, setup and test PlayemJS on your computer: README.md

I will be happy to assist you at any stage, if you want to try to solve this issue! If you have any question, just leave a comment below. Beginners are also welcome! 🤗

BUG: Make sure that next track will start playing, even when page is not active (background)

PlayemJS is a web/js component to play a sequence of tracks from Youtube, Soundcloud, Bandcamp and several other streaming sources. It's the core of openwhyd.org's music web app.


Problem

Found evidence that Google Chrome prevented videos from starting to play when their tab was in the background:

To prevent user annoyance and conserve power, Chrome will now defer playback of autoplay videos in background tabs until the first time the tab is foregrounded.

Source: openwhyd/openwhyd#88 (comment)

Note: this issue does not apply when Playemjs is running in an Electron app. (cf https://github.com/openwhyd/openwhyd-electron)


Howto

In order to solve this issue, you are invited to fork this GitHub repository, makes changes to it, and then create a Pull Request so we can merge your changes back to this repository.

First, you may want to read about:

  • How to install, setup and test PlayemJS on your computer: README.md

I will be happy to assist you at any stage, if you want to try to solve this issue! If you have any question, just leave a comment below. Beginners are also welcome! 🤗

BUG: Dailymotion ads are ignored => skipping to next track

PlayemJS is a web/js component to play a sequence of tracks from Youtube, Soundcloud, Bandcamp and several other streaming sources. It's the core of openwhyd.org's music web app.


Problem

The track https://openwhyd.org/c/54c2160b500cda2b0910a862 does not play when clicking on the "play" icon.


Howto

In order to solve this issue, you are invited to fork this GitHub repository, makes changes to it, and then create a Pull Request so we can merge your changes back to this repository.

First, you may want to read about:

  • How to install, setup and test PlayemJS on your computer: README.md

I will be happy to assist you at any stage, if you want to try to solve this issue! If you have any question, just leave a comment below. Beginners are also welcome! 🤗

Can't find a working demo with audio component and Bandcamp

Hi @adrienjoly,
thanks for your work.
I'm a french front dev / designer. I really really need to make playemjs working on my project, but i can't figure it out how to. I need to run a playlist of streams from Bandcamp + youtube, but i didn't find a working demo. Please help.

all i get is this message on this demo https://codepen.io/adrienjoly/pen/bRRMdQ?editors=1011 :

Loading tests...
If nothing shows up, please open this page using the incognito/private mode of your browser

I have installed the component on a wordpress from scratch theme based on the awesome "Sage roots" developer theme.

I have installed the app with NPM (yarn) (+ composer + node js)
but my (wordpress) demo displays this:

Loading tests...
If nothing shows up, please open this page using the incognito/private mode of your browser

could you please send me a gist and/or a codepen link with a working bandcamp playlist demo to understand what is wrong?
i would be glad to help on this project. I need it on startup prototype to share all good music press release...

regards,

Pierre

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.