Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复发送弹幕BUG #35

Merged
merged 1 commit into from
Feb 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion ede.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,8 @@
const currentTime = _media.currentTime;
const mode = parseInt(document.querySelector('input[name="danmakuMode"]:checked').value);
sendDanmaku(danmakuText, currentTime, mode);
// 清空输入框的值
document.getElementById('danmakuText').value = '';
modal.style.display = 'none';
modal.removeEventListener('keydown', event => event.stopPropagation(), true);
};
Expand Down Expand Up @@ -661,9 +663,10 @@
const json = await resp.json();
if (json.errorCode == 0) {
const colorStr = `000000${color.toString(16)}`.slice(-6);
const modemap = { 6: 'ltr', 1: 'rtl', 5: 'top', 4: 'bottom' }[mode];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我看API文档那里,mode是个数字,你确定是用rtl这种字符串么?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
这个danmaku跟dandanplay的不太一样

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

试了下确实是这样才正常

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

啊,我理解错了,danmaku.js的参数确实是字符串

Copy link
Author

@Xarth-Mai Xarth-Mai Feb 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

往服务器发送的在644行

                const danmakuUrl = apiPrefix + 'https://api.dandanplay.net/api/v2/comment/' + window.ede.episode_info.episodeId;
                const params = {
                    'time': time,
                    'mode': mode,
                    'color': color,
                    'comment': danmakuText
                };
                const resp = await fetch(danmakuUrl, {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json',
                        'Accept': 'application/json',
                        'User-Agent': navigator.userAgent,
                        'Authorization': 'Bearer ' + ddplayStatus.token
                    },
                    body: JSON.stringify(params)
                });

发的还是数字 但是本地播放器这个是转化成字符串

const comment = {
text: danmakuText,
mode: mode,
mode: modemap,
time: time,
style: {
font: `${window.ede.fontSize}px sans-serif`,
Expand Down Expand Up @@ -808,6 +811,10 @@
await new Promise((resolve) => setTimeout(resolve, 200));
let sessionUrl = baseUrl + '/Sessions?ControllableByUserId=' + userId + '&deviceId=' + deviceId;
let sessionInfo = await getSessionInfo(sessionUrl, authorization);
if (!sessionInfo[0].NowPlayingItem) {
await initConfig();
continue;
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个分支进入的前提是已经获取到认证信息了,再调用initConfig是为了换个新的?

Copy link
Author

@Xarth-Mai Xarth-Mai Feb 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

因为在Safari上切后台再回来 不知道Safari做了什么,会导致无法获取sessionInfo[0].NowPlayingItem 所以从头刷新一遍
而且没拿到sessionInfo[0].NowPlayingItem的话后面的代码会直接卡住image

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

哦哦,我没在Safari上测过,那就先这样吧

playingInfo = sessionInfo[0].NowPlayingItem;
}
showDebugInfo('获取Item信息成功: ' + (playingInfo.SeriesName || playingInfo.Name));
Expand Down