mirror of
https://github.com/FreeTubeApp/FreeTube
synced 2024-11-11 13:20:19 +01:00
Fix: Videos not playing and opening YouTube and HookTube links.
This commit is contained in:
parent
96bd02ad24
commit
a5e1db960c
@ -83,9 +83,10 @@ const settingsDb = new Datastore({
|
|||||||
checkDefaultSettings();
|
checkDefaultSettings();
|
||||||
|
|
||||||
require('electron').ipcRenderer.on('ping', function(event, message) {
|
require('electron').ipcRenderer.on('ping', function(event, message) {
|
||||||
|
console.log(message);
|
||||||
let url = message[1].replace('freetube://', '');
|
let url = message[1].replace('freetube://', '');
|
||||||
parseSearchText(url);
|
parseSearchText(url);
|
||||||
console.log(message); // Prints "whoooooooh!"
|
console.log(message);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Open links externally by default
|
// Open links externally by default
|
||||||
|
@ -119,11 +119,11 @@ function playVideo(videoId, videoThumbnail = '', useWindowPlayer = false) {
|
|||||||
Object.keys(videoUrls).forEach((key) => {
|
Object.keys(videoUrls).forEach((key) => {
|
||||||
switch (videoUrls[key]['itag']) {
|
switch (videoUrls[key]['itag']) {
|
||||||
case '18':
|
case '18':
|
||||||
video480p = videoUrls[key]['url'];
|
video480p = decodeURIComponent(videoUrls[key]['url']);
|
||||||
console.log(video480p);
|
console.log(video480p);
|
||||||
break;
|
break;
|
||||||
case '22':
|
case '22':
|
||||||
video720p = videoUrls[key]['url'];
|
video720p = decodeURIComponent(videoUrls[key]['url']);
|
||||||
console.log(video720p);
|
console.log(video720p);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -148,7 +148,7 @@ function playVideo(videoId, videoThumbnail = '', useWindowPlayer = false) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!useEmbedPlayer) {
|
if (!useEmbedPlayer) {
|
||||||
videoHtml = '<video class="videoPlayer" type="application/x-mpegURL" onmousemove="hideMouseTimeout()" onmouseleave="removeMouseTimeout()" controls="" src="' + defaultUrl + '" poster="' + videoThumbnail + '" autoplay>';
|
//videoHtml = '<video class="videoPlayer" type="application/x-mpegURL" onmousemove="hideMouseTimeout()" onmouseleave="removeMouseTimeout()" controls="" src="' + defaultUrl + '" poster="' + videoThumbnail + '" autoplay>';
|
||||||
|
|
||||||
|
|
||||||
if (typeof(info.player_response.captions) === 'object') {
|
if (typeof(info.player_response.captions) === 'object') {
|
||||||
@ -168,7 +168,7 @@ function playVideo(videoId, videoThumbnail = '', useWindowPlayer = false) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
videoHtml = videoHtml + '</video>';
|
//videoHtml = videoHtml + '</video>';
|
||||||
}
|
}
|
||||||
|
|
||||||
const checkSubscription = isSubscribed(channelId);
|
const checkSubscription = isSubscribed(channelId);
|
||||||
@ -192,8 +192,9 @@ function playVideo(videoId, videoThumbnail = '', useWindowPlayer = false) {
|
|||||||
const playerTemplate = require('./templates/player.html')
|
const playerTemplate = require('./templates/player.html')
|
||||||
mustache.parse(playerTemplate);
|
mustache.parse(playerTemplate);
|
||||||
const rendered = mustache.render(playerTemplate, {
|
const rendered = mustache.render(playerTemplate, {
|
||||||
videoHtml: videoHtml,
|
|
||||||
videoQuality: defaultQuality,
|
videoQuality: defaultQuality,
|
||||||
|
subtitleHtml: videoHtml,
|
||||||
|
defaultUrl: defaultUrl,
|
||||||
videoTitle: info['title'],
|
videoTitle: info['title'],
|
||||||
videoViews: videoViews,
|
videoViews: videoViews,
|
||||||
videoThumbnail: videoThumbnail,
|
videoThumbnail: videoThumbnail,
|
||||||
@ -234,7 +235,7 @@ function playVideo(videoId, videoThumbnail = '', useWindowPlayer = false) {
|
|||||||
videoId: videoId,
|
videoId: videoId,
|
||||||
channelId: channelId
|
channelId: channelId
|
||||||
});
|
});
|
||||||
|
|
||||||
newWindow.loadURL('data:text/html;charset=UTF-8,' + encodeURIComponent(playerHeaderRender + rendered), {
|
newWindow.loadURL('data:text/html;charset=UTF-8,' + encodeURIComponent(playerHeaderRender + rendered), {
|
||||||
baseURLForDataURL: `file://${__dirname}/src`
|
baseURLForDataURL: `file://${__dirname}/src`
|
||||||
});
|
});
|
||||||
@ -245,11 +246,6 @@ function playVideo(videoId, videoThumbnail = '', useWindowPlayer = false) {
|
|||||||
|
|
||||||
showVideoRecommendations(videoId);
|
showVideoRecommendations(videoId);
|
||||||
|
|
||||||
// Sometimes a video URL is found, but the video will not play. I believe the issue is
|
|
||||||
// that the video has yet to render for that quality, as the video will be available at a later time.
|
|
||||||
// This will check the URLs and switch video sources if there is an error.
|
|
||||||
checkVideoUrls(video480p, video720p);
|
|
||||||
|
|
||||||
// Hide subtitles by default
|
// Hide subtitles by default
|
||||||
if (typeof(info['subtitles']) !== 'undefined' && Object.keys(info['subtitles']).length > 0) {
|
if (typeof(info['subtitles']) !== 'undefined' && Object.keys(info['subtitles']).length > 0) {
|
||||||
let textTracks = $('.videoPlayer').get(0).textTracks;
|
let textTracks = $('.videoPlayer').get(0).textTracks;
|
||||||
@ -259,7 +255,12 @@ function playVideo(videoId, videoThumbnail = '', useWindowPlayer = false) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sometimes a video URL is found, but the video will not play. I believe the issue is
|
||||||
|
// that the video has yet to render for that quality, as the video will be available at a later time.
|
||||||
|
// This will check the URLs and switch video sources if there is an error.
|
||||||
|
//checkVideoUrls(video480p, video720p);
|
||||||
|
|
||||||
|
window.setTimeout(checkVideoUrls, 5000, video480p, video720p);
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
{{{videoHtml}}}
|
<video class="videoPlayer" type="application/x-mpegURL" onmousemove="hideMouseTimeout()" onmouseleave="removeMouseTimeout()" controls="" src="{{defaultUrl}}" poster="{{videoThumbnail}}" autoplay>
|
||||||
|
{{{subtitleHtml}}}
|
||||||
|
</video>
|
||||||
<div class='statistics'>
|
<div class='statistics'>
|
||||||
<div class='smallButton' onclick="openMiniPlayer('{{videoThumbnail}}')">
|
<div class='smallButton' onclick="openMiniPlayer('{{videoThumbnail}}')">
|
||||||
MINI PLAYER <i class="fas fa-external-link-alt"></i>
|
MINI PLAYER <i class="fas fa-external-link-alt"></i>
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<input type="checkbox" id="themeSwitch" name="set-name" class="switch-input" onchange='toggleTheme(this)' {{isChecked}}>
|
<input type="checkbox" id="themeSwitch" name="set-name" class="switch-input" onchange='toggleTheme(this)' {{isChecked}}>
|
||||||
<label for="themeSwitch" class="switch-label">Use Dark Theme</label>
|
<label for="themeSwitch" class="switch-label">Use Dark Theme</label>
|
||||||
<input type="checkbox" id="torSwitch" name="set-name" class="switch-input" {{isChecked}}>
|
<input type="checkbox" id="torSwitch" name="set-name" class="switch-input" {{isChecked}}>
|
||||||
<label for="torSwitch" class="switch-label">Use TOR for API calls</label>
|
<label for="torSwitch" class="switch-label">Use Tor for API calls</label>
|
||||||
</div>
|
</div>
|
||||||
<div class='center'>
|
<div class='center'>
|
||||||
<div onclick='importSubscriptions()' class='settingsButton'>
|
<div onclick='importSubscriptions()' class='settingsButton'>
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
<ul>
|
<ul>
|
||||||
<li onclick='playVideo("{{videoId}}", "", true); showVideoOptions(this.parentNode.previousSibling);'>Open (New Window)</li>
|
<li onclick='playVideo("{{videoId}}", "", true); showVideoOptions(this.parentNode.previousSibling);'>Open (New Window)</li>
|
||||||
<li onclick='addSavedVideo("{{videoId}}"); showVideoOptions(this.parentNode.previousSibling);'>Save Video</li>
|
<li onclick='addSavedVideo("{{videoId}}"); showVideoOptions(this.parentNode.previousSibling);'>Save Video</li>
|
||||||
<a href='https://youtube.com/watch?v={{videoId}}; showVideoOptions(this.parentNode.previousSibling);' ><li>Open in YouTube</li></a>
|
<a href='https://youtube.com/watch?v={{videoId}}' ><li>Open in YouTube</li></a>
|
||||||
<a href='https://hooktube.com/watch?v={{videoId}}; showVideoOptions(this.parentNode.previousSibling);' ><li>Open in HookTube</li></a>
|
<a href='https://hooktube.com/watch?v={{videoId}}' ><li>Open in HookTube</li></a>
|
||||||
{{{deleteHtml}}}
|
{{{deleteHtml}}}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user