mirror of https://github.com/FreeTubeApp/FreeTube
Add history when clicking to mini player and shrink margin on miniplayer
This commit is contained in:
parent
4151bba5cb
commit
f2b57ebef8
|
@ -48,7 +48,7 @@ function playVideo(videoId, playlistId = '') {
|
||||||
playerView.videoLive = undefined;
|
playerView.videoLive = undefined;
|
||||||
playerView.validLive = false;
|
playerView.validLive = false;
|
||||||
playerView.validDash = true;
|
playerView.validDash = true;
|
||||||
playerView.videoDash = invidiousInstance + '/api/manifest/dash/' + videoId + '.mpd';
|
playerView.videoDash = invidiousInstance + '/api/manifest/dash/' + videoId + '.mpd?unique_res=1';
|
||||||
playerView.embededHtml = "<iframe width='560' height='315' src='https://www.youtube-nocookie.com/embed/" + videoId + "?rel=0' frameborder='0' allow='autoplay; encrypted-media' allowfullscreen></iframe>";
|
playerView.embededHtml = "<iframe width='560' height='315' src='https://www.youtube-nocookie.com/embed/" + videoId + "?rel=0' frameborder='0' allow='autoplay; encrypted-media' allowfullscreen></iframe>";
|
||||||
|
|
||||||
let videoHtml = '';
|
let videoHtml = '';
|
||||||
|
@ -167,19 +167,6 @@ function playVideo(videoId, playlistId = '') {
|
||||||
playerView.currentQuality = '720p';
|
playerView.currentQuality = '720p';
|
||||||
//playerView.videoUrl = playerView.liveManifest;
|
//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 + '<track kind="subtitles" src="' + subtitleUrl + '" srclang="' + caption.languageCode + '" label="' + caption.name.simpleText + '">';
|
|
||||||
});
|
|
||||||
|
|
||||||
playerView.subtitleHtml = videoHtml;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
youtubedlFinished = true;
|
youtubedlFinished = true;
|
||||||
|
|
||||||
|
@ -274,6 +261,16 @@ function playVideo(videoId, playlistId = '') {
|
||||||
playerView.recommendedVideoList = playerView.recommendedVideoList.concat(data);
|
playerView.recommendedVideoList = playerView.recommendedVideoList.concat(data);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (typeof(data.captions) !== 'undefined') {
|
||||||
|
data.captions.forEach((caption) => {
|
||||||
|
let subtitleUrl = invidiousInstance + caption.url;
|
||||||
|
|
||||||
|
videoHtml = videoHtml + '<track kind="subtitles" src="' + subtitleUrl + '" srclang="' + caption.languageCode + '" label="' + caption.label + '">';
|
||||||
|
});
|
||||||
|
|
||||||
|
playerView.subtitleHtml = videoHtml;
|
||||||
|
}
|
||||||
|
|
||||||
if (!getVideosLocally) {
|
if (!getVideosLocally) {
|
||||||
let videoUrls = data.formatStreams;
|
let videoUrls = data.formatStreams;
|
||||||
let formatUrls = data.adaptiveFormats;
|
let formatUrls = data.adaptiveFormats;
|
||||||
|
@ -323,19 +320,6 @@ function playVideo(videoId, playlistId = '') {
|
||||||
playerView.videoAudio = '';
|
playerView.videoAudio = '';
|
||||||
playerView.validAudio = false;
|
playerView.validAudio = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
let useEmbedPlayer = false;
|
|
||||||
|
|
||||||
if (!useEmbedPlayer &&
|
|
||||||
typeof(data.captions) !== 'undefined') {
|
|
||||||
data.captions.forEach((caption) => {
|
|
||||||
let subtitleUrl = invidiousInstance + caption.url;
|
|
||||||
|
|
||||||
videoHtml = videoHtml + '<track kind="subtitles" src="' + subtitleUrl + '" srclang="' + caption.languageCode + '" label="' + caption.label + '">';
|
|
||||||
});
|
|
||||||
|
|
||||||
playerView.subtitleHtml = videoHtml;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.liveNow !== false) {
|
if (data.liveNow !== false) {
|
||||||
|
@ -794,27 +778,27 @@ function clickMiniPlayer(videoId) {
|
||||||
miniPlayer.webContents.send('ping', videoData);
|
miniPlayer.webContents.send('ping', videoData);
|
||||||
showToast('Video has been opened in a new window.');
|
showToast('Video has been opened in a new window.');
|
||||||
// TODO: Add video to history once fully loaded.
|
// TODO: Add video to history once fully loaded.
|
||||||
/*if (rememberHistory === true) {
|
if (rememberHistory === true) {
|
||||||
let historyData = {
|
let historyData = {
|
||||||
videoId: videoId,
|
videoId: videoData.videoId,
|
||||||
published: data.published,
|
published: videoData.published,
|
||||||
publishedText: playerView.publishedDate,
|
publishedText: videoData.publishedText,
|
||||||
description: data.description,
|
description: videoData.description,
|
||||||
viewCount: data.viewCount,
|
viewCount: videoData.viewCount,
|
||||||
title: playerView.videoTitle,
|
title: videoData.videoTitle,
|
||||||
lengthSeconds: data.lengthSeconds,
|
lengthSeconds: videoData.lengthSeconds,
|
||||||
videoThumbnails: playerView.videoThumbnail,
|
videoThumbnails: videoData.videoThumbnail,
|
||||||
author: playerView.channelName,
|
author: videoData.channelName,
|
||||||
authorId: playerView.channelId,
|
authorId: videoData.channelId,
|
||||||
liveNow: false,
|
liveNow: false,
|
||||||
paid: false,
|
paid: false,
|
||||||
type: 'video',
|
type: 'video',
|
||||||
timeWatched: new Date().getTime(),
|
timeWatched: new Date().getTime(),
|
||||||
|
watchProgress: videoData.currentTime,
|
||||||
};
|
};
|
||||||
|
|
||||||
ft.log(historyData);
|
ft.log(historyData);
|
||||||
addToHistory(historyData);
|
addToHistory(historyData);
|
||||||
}*/
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -873,13 +857,20 @@ function clickMiniPlayer(videoId) {
|
||||||
let videoData = {};
|
let videoData = {};
|
||||||
|
|
||||||
videoData.videoId = videoId;
|
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.autoplay = autoplay;
|
||||||
videoData.enableSubtitles = enableSubtitles;
|
videoData.enableSubtitles = enableSubtitles;
|
||||||
videoData.quality = defaultQuality;
|
videoData.quality = defaultQuality;
|
||||||
videoData.defaultPlaybackRate = defaultPlaybackRate;
|
videoData.defaultPlaybackRate = defaultPlaybackRate;
|
||||||
videoData.volume = currentVolume;
|
videoData.volume = currentVolume;
|
||||||
videoData.currentTime = 0;
|
|
||||||
|
historyDb.findOne({
|
||||||
|
videoId: videoData.videoId
|
||||||
|
}, function(err, doc) {
|
||||||
|
if (doc !== null) {
|
||||||
|
videoData.currentTime = doc.watchProgress;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if (defaultPlayer === 'dash') {
|
if (defaultPlayer === 'dash') {
|
||||||
videoData.playerSeen = true;
|
videoData.playerSeen = true;
|
||||||
|
@ -945,7 +936,7 @@ function clickMiniPlayer(videoId) {
|
||||||
videoData.legacySeen = false;
|
videoData.legacySeen = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
let videoHtml;
|
let videoHtml = '';
|
||||||
|
|
||||||
if (typeof(data.captions) !== 'undefined') {
|
if (typeof(data.captions) !== 'undefined') {
|
||||||
data.captions.forEach((caption) => {
|
data.captions.forEach((caption) => {
|
||||||
|
@ -971,6 +962,13 @@ function clickMiniPlayer(videoId) {
|
||||||
|
|
||||||
videoData.videoTitle = data.title;
|
videoData.videoTitle = data.title;
|
||||||
videoData.videoThumbnail = data.videoThumbnails[0].url;
|
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;
|
invidiousFinished = true;
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function invidiousAPI(resource, id, params, success, fail = function(xhr){
|
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;
|
loadingView.seen = false;
|
||||||
}) {
|
}) {
|
||||||
let requestUrl = invidiousInstance + '/api/v1/' + resource + '/' + id + '?' + $.param(params);
|
let requestUrl = invidiousInstance + '/api/v1/' + resource + '/' + id + '?' + $.param(params);
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
body {
|
body {
|
||||||
background-color: #424242;
|
background-color: #424242;
|
||||||
font-family: 'Roboto', sans-serif;
|
font-family: 'Roboto', sans-serif;
|
||||||
|
margin:0;
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
#legacyPlayer {
|
#legacyPlayer {
|
||||||
|
|
Loading…
Reference in New Issue