Skip to content

Commit

Permalink
Merge pull request #508 from SecurityCze/subtitles
Browse files Browse the repository at this point in the history
feat: Improve customization for subtitles
  • Loading branch information
iwalton3 authored Nov 19, 2023
2 parents af7dbab + e853857 commit e557757
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 14 deletions.
10 changes: 8 additions & 2 deletions for-web-developers.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,14 @@ Current Settings:
- Subtitle Section (`subtitles`):
- `placement: string enum`: Controls where subtitles are displayed on the screen. Default: `center,bottom`
- Provided options: [see enum](https://github.com/jellyfin/jellyfin-media-player/blob/7d5943becc1ca672d599887cac9107836c38d337/resources/settings/settings_description.json#L352-L359)
- `color: string enum`: Controls colors of subtitles. Default: `#EEEEEE,#000000`
- Provided options: [see enum](https://github.com/jellyfin/jellyfin-media-player/blob/7d5943becc1ca672d599887cac9107836c38d337/resources/settings/settings_description.json#L364-L371)
- `color: string enum`: Controls colors of subtitles. Default: `#EEEEEE`
- Provided options: [see enum](https://github.com/jellyfin/jellyfin-media-player/blob/master/resources/settings/settings_description.json#L421-L427)
- `border_color: string enum`: Controls font border colors of subtitles. Default: `#000000`
- Provided options: [see enum](https://github.com/jellyfin/jellyfin-media-player/blob/master/resources/settings/settings_description.json#L434-L440)
- `background_color: string enum`: Controls backgroud colors of subtitles. Default: `#CCCCCC`
- Provided options: [see enum](https://github.com/jellyfin/jellyfin-media-player/blob/master/resources/settings/settings_description.json#L447-L453)
- `background_transparency: string enum`: Controls backgroud transparency (in hex) of subtitles. Default: `00`
- Provided options: [see enum](https://github.com/jellyfin/jellyfin-media-player/blob/master/resources/settings/settings_description.json#L460-L464)
- `size: int`: Controls subtitle size. Default is `32`.
- Provided options: [see enum](https://github.com/jellyfin/jellyfin-media-player/blob/7d5943becc1ca672d599887cac9107836c38d337/resources/settings/settings_description.json#L376-L382)

Expand Down
65 changes: 58 additions & 7 deletions resources/settings/settings_description.json
Original file line number Diff line number Diff line change
Expand Up @@ -416,14 +416,52 @@
},
{
"value": "color",
"default": "#EEEEEE,#000000",
"default": "#EEEEEE",
"possible_values": [
[ "#EEEEEE,#000000", "subtitles.lightGrey" ],
[ "#CCCCCC,#000000", "subtitles.blendedLightGrey" ],
[ "#FBF93E,#000000", "subtitles.yellow" ],
[ "#FFFFCC,#000000", "subtitles.lightYellow" ],
[ "#EEEDB8,#000000", "subtitles.blendedLightYellow" ],
[ "#FFFFFF,#000000", "subtitles.blackWhite" ]
[ "#000000", "subtitles.black" ],
[ "#FFFFFF", "subtitles.white" ],
[ "#EEEEEE", "subtitles.lightGrey" ],
[ "#CCCCCC", "subtitles.blendedLightGrey" ],
[ "#FBF93E", "subtitles.yellow" ],
[ "#FFFFCC", "subtitles.lightYellow" ],
[ "#EEEDB8", "subtitles.blendedLightYellow" ]
]
},
{
"value": "border_color",
"default": "#000000",
"possible_values": [
[ "#000000", "subtitles.black" ],
[ "#FFFFFF", "subtitles.white" ],
[ "#EEEEEE", "subtitles.lightGrey" ],
[ "#CCCCCC", "subtitles.blendedLightGrey" ],
[ "#FBF93E", "subtitles.yellow" ],
[ "#FFFFCC", "subtitles.lightYellow" ],
[ "#EEEDB8", "subtitles.blendedLightYellow" ]
]
},
{
"value": "background_color",
"default": "#CCCCCC",
"possible_values": [
[ "#000000", "subtitles.black" ],
[ "#FFFFFF", "subtitles.white" ],
[ "#EEEEEE", "subtitles.lightGrey" ],
[ "#CCCCCC", "subtitles.blendedLightGrey" ],
[ "#FBF93E", "subtitles.yellow" ],
[ "#FFFFCC", "subtitles.lightYellow" ],
[ "#EEEDB8", "subtitles.blendedLightYellow" ]
]
},
{
"value": "background_transparency",
"default": "00",
"possible_values": [
[ "FF", "subtitles.0%" ],
[ "C0", "subtitles.25%" ],
[ "80", "subtitles.50%" ],
[ "40", "subtitles.75%" ],
[ "00", "subtitles.100%" ]
]
},
{
Expand All @@ -436,6 +474,19 @@
[ 42, "subtitles.large" ],
[ 60, "subtitles.huge" ]
]
},
{
"value": "font",
"default": "sans-serif",
"possible_values": [
[ "serif", "serif" ],
[ "sans-serif", "sans-serif" ],
[ "script", "script" ],
[ "monospace", "monospace" ],
[ "display", "display" ],
[ "cursive", "cursive" ],
[ "fantasy", "fantasy" ]
]
}
]
},
Expand Down
29 changes: 24 additions & 5 deletions src/player/PlayerComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1145,12 +1145,31 @@ void PlayerComponent::updateSubtitleSettings()
QVariant size = SettingsComponent::Get().value(SETTINGS_SECTION_SUBTITLES, "size");
mpv::qt::set_property(m_mpv, "sub-scale", size.toInt() / 32.0);

QVariant colorsString = SettingsComponent::Get().value(SETTINGS_SECTION_SUBTITLES, "color");
auto colors = colorsString.toString().split(",");
if (colors.length() == 2)
QString font = SettingsComponent::Get().value(SETTINGS_SECTION_SUBTITLES, "font").toString();
if (!font.isEmpty())
{
mpv::qt::set_property(m_mpv, "sub-color", colors[0]);
mpv::qt::set_property(m_mpv, "sub-border-color", colors[1]);
mpv::qt::set_property(m_mpv, "sub-font", font);
}

QString color = SettingsComponent::Get().value(SETTINGS_SECTION_SUBTITLES, "color").toString();
if (!color.isEmpty())
{
mpv::qt::set_property(m_mpv, "sub-color", color);
}

QString borderColor = SettingsComponent::Get().value(SETTINGS_SECTION_SUBTITLES, "border_color").toString();
if (!borderColor.isEmpty())
{
mpv::qt::set_property(m_mpv, "sub-border-color", borderColor);
}

QString backgroundColor = SettingsComponent::Get().value(SETTINGS_SECTION_SUBTITLES, "background_color").toString();
QString backgroundTransparency = SettingsComponent::Get().value(SETTINGS_SECTION_SUBTITLES, "background_transparency").toString();
if (!backgroundColor.isEmpty() && !backgroundTransparency.isEmpty())
{
// Color is #RRGGBB or #AARRGGBB, insert Alpha after # (at position 1)
backgroundColor.insert(1, backgroundTransparency);
mpv::qt::set_property(m_mpv, "sub-back-color", backgroundColor);
}

QVariant subposString = SettingsComponent::Get().value(SETTINGS_SECTION_SUBTITLES, "placement");
Expand Down

0 comments on commit e557757

Please sign in to comment.