Skip to content

Commit

Permalink
fix: control title
Browse files Browse the repository at this point in the history
  • Loading branch information
zijiren233 committed Dec 8, 2024
1 parent eb1b308 commit fdec3cf
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/plugins/control.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,6 @@ export default function artplayerPluginMediaControl() {

const currentQuality = provider.getCurrentQuality();
const isAuto = provider.isAutoQuality?.() ?? currentQuality === -1;
const defaultLevel = qualities[currentQuality];
const defaultHtml = isAuto ? auto : getName(defaultLevel);

const selector = uniqBy(
qualities.map((item, index) => ({
Expand All @@ -185,11 +183,11 @@ export default function artplayerPluginMediaControl() {
});
}

updateControl("quality", title, defaultHtml, selector, qualityIcon, (item: any) => {
updateControl("quality", title, selector, qualityIcon, (item: any) => {
provider.setQuality(item.value);
art.loading.show = true;
art.notice.show = `${title}: ${item.html}`;
return item.html;
return title;
});
}

Expand All @@ -204,8 +202,6 @@ export default function artplayerPluginMediaControl() {
};

const currentTrack = provider.getCurrentAudioTrack();
const defaultTrack = tracks[currentTrack];
const defaultHtml = getName(defaultTrack);

const selector = uniqBy(
tracks.map((item, index) => ({
Expand All @@ -216,18 +212,17 @@ export default function artplayerPluginMediaControl() {
"html"
);

updateControl("audio", title, defaultHtml, selector, audioIcon, (item: any) => {
updateControl("audio", title, selector, audioIcon, (item: any) => {
provider.setAudioTrack(item.value);
art.loading.show = true;
art.notice.show = `${title}: ${item.html}`;
return item.html;
return title;
});
}

function updateControl(
name: string,
title: string,
defaultHtml: string,
selector: any[],
icon: string,
onSelect: (item: any) => string
Expand All @@ -243,7 +238,7 @@ export default function artplayerPluginMediaControl() {
art.controls.update({
name,
position: "right",
html: defaultHtml,
html: title,
style: { padding: "0 10px" },
selector,
onSelect
Expand All @@ -257,7 +252,6 @@ export default function artplayerPluginMediaControl() {

art.setting.update({
name,
tooltip: defaultHtml,
html: title,
icon,
width: 200,
Expand Down

0 comments on commit fdec3cf

Please sign in to comment.