Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
xjbeta committed Aug 22, 2024
2 parents 1da7270 + 9d748f2 commit 927bb26
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Info.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "Danmaku",
"identifier": "com.xjbeta.danmaku",
"version": "0.1.11",
"ghVersion": 8,
"version": "0.1.12",
"ghVersion": 9,
"ghRepo": "xjbeta/iina-plugin-danmaku",
"description": "IINA Danmaku",
"author": {
Expand Down
29 changes: 23 additions & 6 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,28 @@ function removeOpts() {
};

function parseOpts() {
if (optsParsed) {
removeOpts();
if (optsParsed || mpv.getString('path') != "-") {
return;
};

let scriptOpts = mpv.getString('script-opts').split(',');

let iinaPlusValue = scriptOpts.find(s => s.startsWith(iinaPlusArgsKey));

optsParsed = true;
removeOpts();

if (iinaPlusValue && !stopped) {
optsParsed = true;

let opts = JSON.parse(hexToString(iinaPlusValue.substring(iinaPlusArgsKey.length)));
print('iina plus opts: ' + JSON.stringify(opts));

if (parseFloat(iina.core.getVersion().mpv.replace(/^.*v0\./, '')) >= 38) {
// v0.38.0
mpv.command('loadfile', [opts.urls[opts.currentLine], 'replace', '0', opts.mpvScript]);
} else {
mpv.command('loadfile', [opts.urls[opts.currentLine], 'replace', opts.mpvScript]);
};

iinaPlusOpts = opts;
iinaPlusOpts.mpvScript = undefined;
switch(opts.type) {
Expand Down Expand Up @@ -262,7 +270,11 @@ iina.event.on("iina.window-did-close", () => {
});

function deinit() {
if (stopped) {
return;
};
stopped = true;
setObserver(false);
iinaPlusOpts = undefined;
optsParsed = false;
removeOpts();
Expand All @@ -281,8 +293,13 @@ iina.event.on("iina.file-started", () => {
print('iina.file-started');
stopped = false;
let e = iina.preferences.get('enableIINAPLUSOptsParse');

parseOpts();
let p = mpv.getString('path');
if (p == "-") {
parseOpts();
return;
}
print('Ignore IINA+ Opts Parse, ' + p);
initMenuItems();
});

iina.event.on("mpv.pause.changed", (isPaused) => {
Expand Down

0 comments on commit 927bb26

Please sign in to comment.