Skip to content

Commit

Permalink
youtube player
Browse files Browse the repository at this point in the history
  • Loading branch information
strukturart committed Sep 14, 2024
1 parent 521dbc4 commit 7705593
Show file tree
Hide file tree
Showing 8 changed files with 328 additions and 56 deletions.
89 changes: 41 additions & 48 deletions application/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import DOMPurify from "dompurify";
import {
side_toaster,
sort_array,
imageSizeReduce,
llazyload,
screenlock,
} from "./assets/js/helper.js";
Expand Down Expand Up @@ -46,8 +45,10 @@ import {

import { v4 as uuidv4 } from "uuid";

const dayjs = require("dayjs");
var duration = require("dayjs/plugin/duration");
import dayjs from "dayjs";
import duration from "dayjs/plugin/duration";

// Extend dayjs with the duration plugin
dayjs.extend(duration);

const debug = false;
Expand All @@ -57,7 +58,7 @@ let content_arr = [];
//store all used article ids
var all_cid = [];
let feed_download_list_count = 0;
let panels = ["channels", "recently-played"];
let panels = ["channels"];
let current_panel = 0;
const parser = new DOMParser();

Expand Down Expand Up @@ -1450,6 +1451,10 @@ function nav_panels(left_right) {
});
}, 1000);

if (recently_played.length > 0) {
if (panels.indexOf("recently-played") == -1) panels.push("recently-played");
}

//recently played
if (panels[current_panel] == "recently-played") {
//to do
Expand Down Expand Up @@ -1622,8 +1627,6 @@ let show_article = function () {
document.activeElement.getAttribute("data-id");
} catch (e) {}

console.log(document.activeElement.getAttribute("data-type"));

status.window_status = "single-article";

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

export let toTime = function (seconds) {
let n = "";
if (seconds == "") {
n = "";
} else {
try {
var date = new Date();
date.setSeconds(seconds);
n = date.toISOString().substr(11, 8);
} catch (error) {
n = seconds;
}
}
export let toTime = (seconds) => {
if (seconds === "") return "";

return n;
try {
return dayjs().startOf("day").add(seconds, "second").format("HH:mm:ss");
} catch (error) {
return seconds;
}
};

let youtube_seeking = function (param) {
Expand Down Expand Up @@ -1851,23 +1847,28 @@ let open_url = () => {
let t;

function onPlayerStateChange(event) {
if (event.data == YT.PlayerState.PLAYING) {
youtube_status = "playing";
bottom_bar("<img src='assets/icons/23EF.svg'>", toTime(t), "");
console.log("status: " + event.data);
if (event.data == 1) {
tt();
// screenlock("lock");
bottom_bar("<img src='assets/icons/23EF.svg'>", toTime(t), "");

youtube_status = "playing";
}

if (event.data == YT.PlayerState.PAUSED) {
if (event.data == 2) {
youtube_status = "paused";
clearInterval(youtube_time);
// screenlock("unlock");

screenlock("unlock");
}
}

function onPlayerReady(event) {
event.target.playVideo();
document.querySelector(".loading-spinner").style.display = "none";
bottom_bar("<img src='assets/icons/23EF.svg'>", toTime(t), "");

screenlock("lock");
}

return;
Expand Down Expand Up @@ -2064,7 +2065,7 @@ const show_article_option = () => {
});
} else {
document.querySelectorAll(".mastodon-item").forEach((e) => {
e.style.display = "flex";
e.style.display = "none";
});
}
};
Expand Down Expand Up @@ -2324,24 +2325,17 @@ let remove_alarm = function () {
// KaiOs 2.xx

try {
let request = navigator.mozAlarms.getAll();
var request = navigator.mozAlarms.getAll();

request.onsuccess = function () {
// Remove all pending alarms
this.result.forEach(function (alarm) {
let r = navigator.mozAlarms.remove(alarm.id);

r.onsuccess = function () {
console.log("removed");
};

r.onerror = function () {
console.log("An error occurred: " + this.error.name);
};
navigator.mozAlarms.remove(alarm.id);
});
};

request.onerror = function () {
console.log("An error occurred:", this.error.name);
console.log("operation failed: " + this.error);
};
} catch (e) {}

Expand Down Expand Up @@ -2570,12 +2564,6 @@ function shortpress_action(param) {
sleep_mode();
break;

case "4":
break;

case "8":
break;

case "7":
status.tabsort == "string" ? sort_tab("date") : sort_tab("string");

Expand Down Expand Up @@ -2827,6 +2815,14 @@ function shortpress_action(param) {
break;
}

if (
status.window_status == "single-article" &&
document.activeElement.getAttribute("data-media") == "video"
) {
open_url();
break;
}

if (
status.window_status == "single-article" &&
document.activeElement.getAttribute("data-media") == "youtube"
Expand Down Expand Up @@ -2916,10 +2912,6 @@ function shortpress_action(param) {
case "EndCall":
break;

case "9":
sync();
break;

case "Backspace":
if (status.window_status == "intro") {
bottom_bar("", "", "");
Expand Down Expand Up @@ -3027,6 +3019,7 @@ function shortpress_action(param) {
////////////////////////////////

function handleKeyDown(evt) {
console.log(status.window_status);
if (evt.key === "Backspace" && status.window_status != "article-list") {
evt.preventDefault();
}
Expand Down
1 change: 0 additions & 1 deletion application/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ <h2>Settings</h2>
<label for="time">automatic download of new content</label>
<select id="time" class="select-box">
<option value="never">on start</option>
<option value="2">2min</option>
<option value="20">20min</option>
<option value="40">40min</option>
<option value="60">1h</option>
Expand Down
2 changes: 1 addition & 1 deletion application/manifest.webapp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "2.0.3",
"version": "2.0.6",
"name": "feedolin",
"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.",
"launch_path": "/index.html",
Expand Down
2 changes: 1 addition & 1 deletion application/manifest.webmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
],

"b2g_features": {
"version": "1.7.7",
"version": "1.7.99",
"id": "feedolin",
"subtitle": "RSS Reader and Mastodon Client",
"core": true,
Expand Down
Loading

0 comments on commit 7705593

Please sign in to comment.