diff --git a/src/js/player.js b/src/js/player.js index 494f23cb6..ef3dada75 100644 --- a/src/js/player.js +++ b/src/js/player.js @@ -48,7 +48,7 @@ function playVideo(videoId, playlistId = '') { playerView.videoLive = undefined; playerView.validLive = false; playerView.validDash = true; - playerView.videoDash = invidiousInstance + '/api/manifest/dash/' + videoId + '.mpd'; + playerView.videoDash = invidiousInstance + '/api/manifest/dash/' + videoId + '.mpd?unique_res=1'; playerView.embededHtml = ""; let videoHtml = ''; @@ -167,19 +167,6 @@ function playVideo(videoId, playlistId = '') { playerView.currentQuality = '720p'; //playerView.videoUrl = playerView.liveManifest; } - - if (!useEmbedPlayer && - typeof(data.player_response.captions) !== 'undefined' && - typeof(data.player_response.captions.playerCaptionsTracklistRenderer) !== 'undefined' && - typeof(data.player_response.captions.playerCaptionsTracklistRenderer.captionTracks) !== 'undefined') { - data.player_response.captions.playerCaptionsTracklistRenderer.captionTracks.forEach((caption) => { - let subtitleUrl = invidiousInstance + '/api/v1/captions/' + videoId + '?label=' + caption.name.simpleText; - - videoHtml = videoHtml + ''; - }); - - playerView.subtitleHtml = videoHtml; - } } youtubedlFinished = true; @@ -274,6 +261,16 @@ function playVideo(videoId, playlistId = '') { playerView.recommendedVideoList = playerView.recommendedVideoList.concat(data); }); + if (typeof(data.captions) !== 'undefined') { + data.captions.forEach((caption) => { + let subtitleUrl = invidiousInstance + caption.url; + + videoHtml = videoHtml + ''; + }); + + playerView.subtitleHtml = videoHtml; + } + if (!getVideosLocally) { let videoUrls = data.formatStreams; let formatUrls = data.adaptiveFormats; @@ -323,19 +320,6 @@ function playVideo(videoId, playlistId = '') { playerView.videoAudio = ''; playerView.validAudio = false; } - - let useEmbedPlayer = false; - - if (!useEmbedPlayer && - typeof(data.captions) !== 'undefined') { - data.captions.forEach((caption) => { - let subtitleUrl = invidiousInstance + caption.url; - - videoHtml = videoHtml + ''; - }); - - playerView.subtitleHtml = videoHtml; - } } if (data.liveNow !== false) { @@ -794,27 +778,27 @@ function clickMiniPlayer(videoId) { miniPlayer.webContents.send('ping', videoData); showToast('Video has been opened in a new window.'); // TODO: Add video to history once fully loaded. - /*if (rememberHistory === true) { + if (rememberHistory === true) { let historyData = { - videoId: videoId, - published: data.published, - publishedText: playerView.publishedDate, - description: data.description, - viewCount: data.viewCount, - title: playerView.videoTitle, - lengthSeconds: data.lengthSeconds, - videoThumbnails: playerView.videoThumbnail, - author: playerView.channelName, - authorId: playerView.channelId, + videoId: videoData.videoId, + published: videoData.published, + publishedText: videoData.publishedText, + description: videoData.description, + viewCount: videoData.viewCount, + title: videoData.videoTitle, + lengthSeconds: videoData.lengthSeconds, + videoThumbnails: videoData.videoThumbnail, + author: videoData.channelName, + authorId: videoData.channelId, liveNow: false, paid: false, type: 'video', timeWatched: new Date().getTime(), + watchProgress: videoData.currentTime, }; - ft.log(historyData); addToHistory(historyData); - }*/ + } }); return; @@ -873,13 +857,20 @@ function clickMiniPlayer(videoId) { let videoData = {}; videoData.videoId = videoId; - videoData.videoDash = invidiousInstance + '/api/manifest/dash/' + videoId + '.mpd'; + videoData.videoDash = invidiousInstance + '/api/manifest/dash/' + videoId + '.mpd?unique_res=1'; videoData.autoplay = autoplay; videoData.enableSubtitles = enableSubtitles; videoData.quality = defaultQuality; videoData.defaultPlaybackRate = defaultPlaybackRate; videoData.volume = currentVolume; - videoData.currentTime = 0; + + historyDb.findOne({ + videoId: videoData.videoId + }, function(err, doc) { + if (doc !== null) { + videoData.currentTime = doc.watchProgress; + } + }); if (defaultPlayer === 'dash') { videoData.playerSeen = true; @@ -945,7 +936,7 @@ function clickMiniPlayer(videoId) { videoData.legacySeen = false; } - let videoHtml; + let videoHtml = ''; if (typeof(data.captions) !== 'undefined') { data.captions.forEach((caption) => { @@ -971,6 +962,13 @@ function clickMiniPlayer(videoId) { videoData.videoTitle = data.title; videoData.videoThumbnail = data.videoThumbnails[0].url; + videoData.channelName = data.author; + videoData.channelId = data.authorId; + videoData.lengthSeconds = data.lengthSeconds; + videoData.published = data.published; + videoData.publishedText = data.publishedText; + videoData.description = data.description; + videoData.viewCount = data.viewCount; invidiousFinished = true; diff --git a/src/js/youtubeApi.js b/src/js/youtubeApi.js index 8fa872ab2..daa0effcc 100644 --- a/src/js/youtubeApi.js +++ b/src/js/youtubeApi.js @@ -26,7 +26,12 @@ */ function invidiousAPI(resource, id, params, success, fail = function(xhr){ - showToast('Invidious API Error: ' + xhr.responseJSON.error); + if (typeof(xhr.responseJSON.error) !== 'undefined') { + showToast('Invidious API Error: ' + xhr.responseJSON.error); + } + else { + showToast('There was an error calling the Invidious API'); + } loadingView.seen = false; }) { let requestUrl = invidiousInstance + '/api/v1/' + resource + '/' + id + '?' + $.param(params); diff --git a/src/templates/miniPlayer.html b/src/templates/miniPlayer.html index 39a727d36..3452fdfcc 100644 --- a/src/templates/miniPlayer.html +++ b/src/templates/miniPlayer.html @@ -19,6 +19,8 @@ body { background-color: #424242; font-family: 'Roboto', sans-serif; + margin:0; + overflow: hidden; } #legacyPlayer {