From 2fb43b059dc50c5126587e7a04b0a9fa14823e15 Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 7 Nov 2018 08:57:53 -0600 Subject: [PATCH] Choose higher-quality audio stream URL (#189) * Choose higher-quality audio stream URL This change is kind of a shortcut that is a temporary fix before FreeTube migrates to using the adaptive formats to choose the streaming option URLs. * Higher quality audio stream fixed typo --- src/js/player.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/js/player.js b/src/js/player.js index 33602e480..04d489c7b 100644 --- a/src/js/player.js +++ b/src/js/player.js @@ -68,8 +68,9 @@ function playVideo(videoId, playlistId = '') { playerView.channelName = data.author; playerView.channelId = data.authorId; playerView.channelIcon = data.authorThumbnails[2].url; - + let videoUrls = data.formatStreams; + let formatUrls = data.adaptiveFormats; // Add commas to the video view count. playerView.videoViews = data.viewCount.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); @@ -94,12 +95,11 @@ function playVideo(videoId, playlistId = '') { playerView.video720p = decodeURIComponent(videoUrls[key]['url']); //console.log(video720p); break; - case '36': - playerView.videoAudio = decodeURIComponent(videoUrls[key]['url']); - //console.log(video720p); - break; } }); + + // Last adaptive format will be best the quality audio stream (migrate fully to adaptive formats later) + playerView.videoAudio = decodeURIComponent(formatUrls[formatUrls.length - 1]['url']); if (typeof(playerView.videoAudio) === 'undefined') { playerView.validAudio = false;