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

tvOS subtitle font size and color not working #568

Closed
Alanko5 opened this issue Oct 4, 2023 · 0 comments
Closed

tvOS subtitle font size and color not working #568

Alanko5 opened this issue Oct 4, 2023 · 0 comments

Comments

@Alanko5
Copy link

Alanko5 commented Oct 4, 2023

Is your feature request related to a problem? Please describe.
On tv app is subtitles is too small
because the setting for the string attribute is not applied

Describe the solution you'd like
Need update SubtitlePart.text to NSMutableAttributedString
Create propery var textAttribute: [NSAttributedString.Key : Any] = [:] in VideoPlayerView
in method ``updateSrt()configure textAttributetextAttribute = [.font: SubtitleModel.textFont]```
and then update patrs:

if srtControl.subtitle(currentTime: currentTime) {
            if let part = srtControl.parts.first {
                subtitleBackView.image = part.image
                
                if let lenght = part.text?.length {
                    part.text?.addAttributes(textAttribute,
                                             range: NSRange(location: 0,
                                                            length: lenght))
                }
                subtitleLabel.attributedText = part.text
                subtitleBackView.isHidden = false
            } else {
                subtitleBackView.image = nil
                subtitleLabel.attributedText = nil
                subtitleBackView.isHidden = true
            }
        }

Additional context
and need update SubtitleModel.Size for tvOS:

public enum Size {
        case smaller
        case standard
        case large
        public var rawValue: CGFloat {
            switch self {
            case .smaller:
                #if os(tvOS)
                return 48
                #elseif os(macOS)
                return 20
                #else
                return 12
                #endif
            case .standard:
                #if os(tvOS)
                return 58
                #elseif os(macOS)
                return 26
                #else
                return 16
                #endif
            case .large:
                #if os(tvOS)
                return 68
                #elseif os(macOS)
                return 32
                #else
                return 20
                #endif
            }
        }
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant