Skip to content

Commit

Permalink
Added quality + forcequality options
Browse files Browse the repository at this point in the history
  • Loading branch information
hopollo committed Aug 22, 2021
1 parent 9e6f3fc commit 17ca630
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 20 deletions.
41 changes: 23 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,34 @@
# OBS-Youtube-Player

Designed for OBS Browser source to display/play a song/playlist fully automaticly with customs fixed params.

## Usage : add ? at the end of the link and copy Youtube link from "watch?v=XXXXX" or "watch?v=XXXXX&list=XXXXX")

exemple : https://hopollo.github.io/OBS-Youtube-Player/?watch?v=lSqnqSSXTUI&list=RDlSqnqSSXTUI&volume=10&random=true&loop=true

## Tutorial (video with subtitles instructions): https://youtu.be/y8VerA88A6U

## Features :
**volume :** Volume of the video player : &volume=VALUE (0 to 100, default is 45)\
**w:** Width of the video player : &width=VALUE (default is 535) \
**h:** Height of the video player : &height=VALUE (default is 300)\
**hide:** Hide the video player : &hide=true|false (default is false)\
**loop:** Loop video/playlist when finished : &loop=true|false (default is true)\
**random:** Randomize next song on playlist : &random=true|false (default is true)\
**fade:** Enable the volume fade on song start & end : &fade=true|false (default is true)\
**debug:** Enable debug mode & show info on console : &debug=true|false (default is false)

**volume :** Volume of the video player : &volume=VALUE (0 to 100, default is 45)\
**w:** Width of the video player : &width=VALUE (default is 535) \
**h:** Height of the video player : &height=VALUE (default is 300)\
**hide:** Hide the video player : &hide=true|false (default is false)\
**quality** Video quality of the player : &quality=small|medium|large|hd720|hd1080|highres|default (default is default)\
**forcequality** Enforce choosen video quality : forcequality=true|false (default is false)\
**loop:** Loop video/playlist when finished : &loop=true|false (default is true)\
**random:** Randomize next song on playlist : &random=true|false (default is true)\
**fade:** Enable the volume fade on song start & end : &fade=true|false (default is true)\
**debug:** Enable debug mode & show info on console : &debug=true|false (default is false)

## Built-in features by default :
autoplay = enabled,
Video controls (play,next, etc..) = hidden,
Fullscreen button = hidden,
Video info = hidden,
Loop mode = enabled,
Fade = enabled,
Randomize = enabled,
Video annotation = disabled,
and more....

autoplay = enabled,
Video controls (play,next, etc..) = hidden,
Fullscreen button = hidden,
Video info = hidden,
Loop mode = enabled,
Fade = enabled,
Randomize = enabled,
Video annotation = disabled,
and more....
17 changes: 15 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
let volume = url.searchParams.get("volume") || 45;
let width = url.searchParams.get("w") || 534;
let height = url.searchParams.get("h") || 300;
let quality = url.searchParams.get("quality") || 'default';
let forceQuality = url.searchParams.get('forcequality') || false;
let startSeconds = url.searchParams.get("t");
let index = url.searchParams.get("index") || 0;
let random = url.searchParams.get("random") || true;
Expand Down Expand Up @@ -66,7 +68,7 @@
events: {
onReady,
onStateChange,
//onPlaybackQualityChange, Not useful for now?
onPlaybackQualityChange,
onError,
}
});
Expand All @@ -75,8 +77,13 @@
function onReady(event) {
// Enforcing defaults params
player.setVolume(volume);
player.getPlaybackRate(1);
// Apply choosen video quality
player.setPlaybackQuality(quality);
// Enforce 1x speed, just in case
player.setPlaybackRate(1);
// Toggle looping
(loop === 'true') ? player.setLoop(true) : player.setLoop(false);
// Toogle randomize
(random === 'true') ? player.setShuffle(true) : player.setShuffle(false);

if (songID && listID) {
Expand Down Expand Up @@ -136,6 +143,11 @@
}
}

function onPlaybackQualityChange() {
console.log(`Video quality changed by Youtube${forceQuality ? ', trying to force it back' : ''}`);
forceQuality ? player.setPlaybackQuality(quality) : null;
}

function onError() {
console.log("Error detected, video skipped");
player.nextVideo();
Expand All @@ -146,6 +158,7 @@
Queue position => ${player.getPlaylistIndex() + 1}/${(player.getPlaylist()) ? player.getPlaylist().length : null}
Start at => ${(startSeconds) ? startSeconds : 0}s/${Math.round(Math.floor(player.getDuration()))}s
Volume => ${volume}%
Quality => ${player.getPlaybackQuality()}/${quality} (forced: ${forceQuality})
Fade => ${fade}
Randomize => ${random}
Loop => ${loop}
Expand Down

0 comments on commit 17ca630

Please sign in to comment.