mirror of
https://gitlab.com/futo-org/fcast.git
synced 2025-08-08 02:02:49 +00:00
Finished first version of Chrome extension to cast to FCast. Added support for WebSocket to terminal client. Added global support for setting playback speed. Added support for casting local file using terminal client. Added global support for playback error messages. Fixed crash caused by failing to unregister MDNS. Fixed issue where subtitles would always show for HLS. Added support for fractional seconds globally. Layout fixes to desktop casting client. Added footer telling user they can close the window.
This commit is contained in:
parent
fd9a63dac0
commit
18b61d549c
26 changed files with 1116 additions and 193 deletions
|
@ -2,7 +2,9 @@ let mediaUrls = [];
|
|||
let hosts = [];
|
||||
let currentWebSocket = null;
|
||||
let playbackState = null;
|
||||
let playbackStateUpdateTime = null;
|
||||
let volume = 1.0;
|
||||
let volumeUpdateTime = null;
|
||||
let selectedHost = null;
|
||||
|
||||
const Opcode = {
|
||||
|
@ -35,7 +37,6 @@ chrome.runtime.onInstalled.addListener(function() {
|
|||
|
||||
chrome.webRequest.onHeadersReceived.addListener(
|
||||
function(details) {
|
||||
console.log(`onHeadersReceived (${details.url})`, details);
|
||||
const contentType = details.responseHeaders.find(header => header.name.toLowerCase() === 'content-type')?.value;
|
||||
if (!contentType) {
|
||||
return;
|
||||
|
@ -48,10 +49,16 @@ chrome.webRequest.onHeadersReceived.addListener(
|
|||
const isSegment = details.url.endsWith(".ts");
|
||||
|
||||
if (contentType && isMedia && !isSegment) {
|
||||
if (!mediaUrls.some(v => v.url === details.url))
|
||||
mediaUrls.push({contentType, url: details.url});
|
||||
console.log('Media URL found:', {contentType, url: details.url});
|
||||
notifyPopup('updateUrls');
|
||||
|
||||
if (!mediaUrls.some(v => v.url === details.url)) {
|
||||
mediaUrls.unshift({contentType, url: details.url});
|
||||
if (mediaUrls.length > 5) {
|
||||
mediaUrls.pop();
|
||||
}
|
||||
|
||||
notifyPopup('updateUrls');
|
||||
}
|
||||
}
|
||||
},
|
||||
{ urls: ["<all_urls>"] },
|
||||
|
@ -114,6 +121,8 @@ chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
|
|||
} else if (request.action === 'stop') {
|
||||
stop(selectedHost);
|
||||
} else if (request.action === 'setVolume') {
|
||||
volumeUpdateTime = Date.now();
|
||||
volume = request.volume;
|
||||
setVolume(selectedHost, request.volume);
|
||||
} else if (request.action === 'seek') {
|
||||
seek(selectedHost, request.time);
|
||||
|
@ -241,8 +250,10 @@ function maintainWebSocketConnection(host) {
|
|||
try {
|
||||
const playbackUpdateMsg = JSON.parse(body);
|
||||
console.log("Received playback update", playbackUpdateMsg);
|
||||
playbackState = playbackUpdateMsg;
|
||||
notifyPopup('updatePlaybackState');
|
||||
if (playbackStateUpdateTime == null || playbackStateUpdateTime.generationTime > playbackStateUpdateTime) {
|
||||
playbackState = playbackUpdateMsg;
|
||||
notifyPopup('updatePlaybackState');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error parsing playback update message:", error);
|
||||
}
|
||||
|
@ -254,8 +265,11 @@ function maintainWebSocketConnection(host) {
|
|||
try {
|
||||
const volumeUpdateMsg = JSON.parse(body);
|
||||
console.log("Received volume update", volumeUpdateMsg);
|
||||
volume = volumeUpdateMsg;
|
||||
notifyPopup('updateVolume');
|
||||
if (volumeUpdateTime == null || volumeUpdateMsg.generationTime > volumeUpdateTime) {
|
||||
volume = volumeUpdateMsg.volume;
|
||||
volumeUpdateTime = volumeUpdateMsg.generationTime;
|
||||
notifyPopup('updateVolume');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error parsing volume update message:", error);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue