Giter Club home page Giter Club logo

youtube-sync's Introduction

CircleCI

gui1

๐Ÿ•œ Sync youtube playback between browsers ๐Ÿ•™

This is an application that syncs youtube playback between connected users using websockets. The entire thing is build with scala. Akka on the backend and ScalaJS on the frontend side.

How it works

When a room is created, the creator is granted the "leader" status. The server will now take his status and will force every other user to sync to this status. Every client loads his own youtube player so theres no real overhead on playing the videos themself. If someone is loading slow and not able to keep up this has no impact on other users. The server will just keep requesting the slow loading player to adjust to the leader, until it catches up. If the room leader is slow / has buffering problems this will reflect back on the other users in the room as they will be synced back to where the leader is. This in practice wont result in stuttering as playstate is also taken into consideration. If the playstate of the leader is buffering, the rest will also be set to buffering rather than keep playing and syncing back to the leader every few seconds.

Theres a small offset allowed in synchronisation between clients and leader (2 seconds) because in practice keeping sync on milliseconds is not worth the potential gains for our application. This offset can be changed in checkForUpdate method in Frontend.scala.

The server status ticks are every 5 second. This means every 5 seconds all users are checked for status and are candidate for potential updates.

If autoplay is on or next is called and there is no more video in the playlist, elevator music will be played.

Running version can be found at www.youtube-sync.nl

Usage

Build using docker

In the root of the project there is a build.sh file. This will build the project inside a container, output a jar, and finally build a docker image with the app called rlemmens/youtube-sync with tag latest. This is the easiest way of getting started without needing scala or sbt on your local machine.

Developing

First fire up a SBT session in the root folder. Then:

project backend

followed by:

reStart

The backend should now be running. The frontend will also be build and served through akka. Access the site by going to localhost:8080

If you want to build only the JS files do:

project frontend

followed by:

fastOptJS

You will need a copy of the index.html in the resource folder of the backend project and point that copy towards the build JS if you want to build the frontend without the backend.

Build a jar

First fire up a SBT session in the root folder. Then:

project backend

followed by:

assembly

This will build a standalone jar ready for deployment.

Todo

  • Create a better build. One that starts backend and serves the generated frontend HTML through the backend for easy deployment. Done.
  • Refactor towards a somewhat more functional construct

youtube-sync's People

Contributors

robertlemmens avatar mik13st 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.