Skip to content

Commit 7705593

Browse files
committed
youtube player
1 parent 521dbc4 commit 7705593

File tree

8 files changed

+328
-56
lines changed

8 files changed

+328
-56
lines changed

application/app.js

Lines changed: 41 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import DOMPurify from "dompurify";
66
import {
77
side_toaster,
88
sort_array,
9-
imageSizeReduce,
109
llazyload,
1110
screenlock,
1211
} from "./assets/js/helper.js";
@@ -46,8 +45,10 @@ import {
4645

4746
import { v4 as uuidv4 } from "uuid";
4847

49-
const dayjs = require("dayjs");
50-
var duration = require("dayjs/plugin/duration");
48+
import dayjs from "dayjs";
49+
import duration from "dayjs/plugin/duration";
50+
51+
// Extend dayjs with the duration plugin
5152
dayjs.extend(duration);
5253

5354
const debug = false;
@@ -57,7 +58,7 @@ let content_arr = [];
5758
//store all used article ids
5859
var all_cid = [];
5960
let feed_download_list_count = 0;
60-
let panels = ["channels", "recently-played"];
61+
let panels = ["channels"];
6162
let current_panel = 0;
6263
const parser = new DOMParser();
6364

@@ -1450,6 +1451,10 @@ function nav_panels(left_right) {
14501451
});
14511452
}, 1000);
14521453

1454+
if (recently_played.length > 0) {
1455+
if (panels.indexOf("recently-played") == -1) panels.push("recently-played");
1456+
}
1457+
14531458
//recently played
14541459
if (panels[current_panel] == "recently-played") {
14551460
//to do
@@ -1622,8 +1627,6 @@ let show_article = function () {
16221627
document.activeElement.getAttribute("data-id");
16231628
} catch (e) {}
16241629

1625-
console.log(document.activeElement.getAttribute("data-type"));
1626-
16271630
status.window_status = "single-article";
16281631

16291632
let elem = document.querySelectorAll("article");
@@ -1703,21 +1706,14 @@ let show_article = function () {
17031706
document.getElementById("top-bar").style.display = "none";
17041707
};
17051708

1706-
export let toTime = function (seconds) {
1707-
let n = "";
1708-
if (seconds == "") {
1709-
n = "";
1710-
} else {
1711-
try {
1712-
var date = new Date();
1713-
date.setSeconds(seconds);
1714-
n = date.toISOString().substr(11, 8);
1715-
} catch (error) {
1716-
n = seconds;
1717-
}
1718-
}
1709+
export let toTime = (seconds) => {
1710+
if (seconds === "") return "";
17191711

1720-
return n;
1712+
try {
1713+
return dayjs().startOf("day").add(seconds, "second").format("HH:mm:ss");
1714+
} catch (error) {
1715+
return seconds;
1716+
}
17211717
};
17221718

17231719
let youtube_seeking = function (param) {
@@ -1851,23 +1847,28 @@ let open_url = () => {
18511847
let t;
18521848

18531849
function onPlayerStateChange(event) {
1854-
if (event.data == YT.PlayerState.PLAYING) {
1855-
youtube_status = "playing";
1856-
bottom_bar("<img src='assets/icons/23EF.svg'>", toTime(t), "");
1850+
console.log("status: " + event.data);
1851+
if (event.data == 1) {
18571852
tt();
1858-
// screenlock("lock");
1853+
bottom_bar("<img src='assets/icons/23EF.svg'>", toTime(t), "");
1854+
1855+
youtube_status = "playing";
18591856
}
18601857

1861-
if (event.data == YT.PlayerState.PAUSED) {
1858+
if (event.data == 2) {
18621859
youtube_status = "paused";
18631860
clearInterval(youtube_time);
1864-
// screenlock("unlock");
1861+
1862+
screenlock("unlock");
18651863
}
18661864
}
18671865

18681866
function onPlayerReady(event) {
18691867
event.target.playVideo();
18701868
document.querySelector(".loading-spinner").style.display = "none";
1869+
bottom_bar("<img src='assets/icons/23EF.svg'>", toTime(t), "");
1870+
1871+
screenlock("lock");
18711872
}
18721873

18731874
return;
@@ -2064,7 +2065,7 @@ const show_article_option = () => {
20642065
});
20652066
} else {
20662067
document.querySelectorAll(".mastodon-item").forEach((e) => {
2067-
e.style.display = "flex";
2068+
e.style.display = "none";
20682069
});
20692070
}
20702071
};
@@ -2324,24 +2325,17 @@ let remove_alarm = function () {
23242325
// KaiOs 2.xx
23252326

23262327
try {
2327-
let request = navigator.mozAlarms.getAll();
2328+
var request = navigator.mozAlarms.getAll();
23282329

23292330
request.onsuccess = function () {
2331+
// Remove all pending alarms
23302332
this.result.forEach(function (alarm) {
2331-
let r = navigator.mozAlarms.remove(alarm.id);
2332-
2333-
r.onsuccess = function () {
2334-
console.log("removed");
2335-
};
2336-
2337-
r.onerror = function () {
2338-
console.log("An error occurred: " + this.error.name);
2339-
};
2333+
navigator.mozAlarms.remove(alarm.id);
23402334
});
23412335
};
23422336

23432337
request.onerror = function () {
2344-
console.log("An error occurred:", this.error.name);
2338+
console.log("operation failed: " + this.error);
23452339
};
23462340
} catch (e) {}
23472341

@@ -2570,12 +2564,6 @@ function shortpress_action(param) {
25702564
sleep_mode();
25712565
break;
25722566

2573-
case "4":
2574-
break;
2575-
2576-
case "8":
2577-
break;
2578-
25792567
case "7":
25802568
status.tabsort == "string" ? sort_tab("date") : sort_tab("string");
25812569

@@ -2827,6 +2815,14 @@ function shortpress_action(param) {
28272815
break;
28282816
}
28292817

2818+
if (
2819+
status.window_status == "single-article" &&
2820+
document.activeElement.getAttribute("data-media") == "video"
2821+
) {
2822+
open_url();
2823+
break;
2824+
}
2825+
28302826
if (
28312827
status.window_status == "single-article" &&
28322828
document.activeElement.getAttribute("data-media") == "youtube"
@@ -2916,10 +2912,6 @@ function shortpress_action(param) {
29162912
case "EndCall":
29172913
break;
29182914

2919-
case "9":
2920-
sync();
2921-
break;
2922-
29232915
case "Backspace":
29242916
if (status.window_status == "intro") {
29252917
bottom_bar("", "", "");
@@ -3027,6 +3019,7 @@ function shortpress_action(param) {
30273019
////////////////////////////////
30283020

30293021
function handleKeyDown(evt) {
3022+
console.log(status.window_status);
30303023
if (evt.key === "Backspace" && status.window_status != "article-list") {
30313024
evt.preventDefault();
30323025
}

application/index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ <h2>Settings</h2>
197197
<label for="time">automatic download of new content</label>
198198
<select id="time" class="select-box">
199199
<option value="never">on start</option>
200-
<option value="2">2min</option>
201200
<option value="20">20min</option>
202201
<option value="40">40min</option>
203202
<option value="60">1h</option>

application/manifest.webapp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "2.0.3",
2+
"version": "2.0.6",
33
"name": "feedolin",
44
"description": "Feedolin is an RSS / Atom / Mastodon reader and podcast player. It is intended for users who already use an rss reader client and want to read their feeds on a kaios device. the list of subscribed websites / podcasts is managed locally or online in an opml file.",
55
"launch_path": "/index.html",

application/manifest.webmanifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
],
2222

2323
"b2g_features": {
24-
"version": "1.7.7",
24+
"version": "1.7.99",
2525
"id": "feedolin",
2626
"subtitle": "RSS Reader and Mastodon Client",
2727
"core": true,

0 commit comments

Comments
 (0)