mirror of
https://github.com/streamyfin/streamyfin.git
synced 2025-08-20 18:37:18 +02:00
feat: scale factor and aspect ratio (#942)
This commit is contained in:
committed by
GitHub
parent
4fed25a3ab
commit
9410239c48
@@ -92,7 +92,9 @@ export interface VlcPlayerViewRef {
|
||||
nextChapter: () => Promise<void>;
|
||||
previousChapter: () => Promise<void>;
|
||||
getChapters: () => Promise<ChapterInfo[] | null>;
|
||||
setVideoCropGeometry: (geometry: string | null) => Promise<void>;
|
||||
setVideoCropGeometry: (cropGeometry: string | null) => Promise<void>;
|
||||
getVideoCropGeometry: () => Promise<string | null>;
|
||||
setSubtitleURL: (url: string) => Promise<void>;
|
||||
setVideoAspectRatio: (aspectRatio: string | null) => Promise<void>;
|
||||
setVideoScaleFactor: (scaleFactor: number) => Promise<void>;
|
||||
}
|
||||
|
||||
@@ -86,6 +86,12 @@ const VlcPlayerView = React.forwardRef<VlcPlayerViewRef, VlcPlayerViewProps>(
|
||||
setSubtitleURL: async (url: string) => {
|
||||
await nativeRef.current?.setSubtitleURL(url);
|
||||
},
|
||||
setVideoAspectRatio: async (aspectRatio: string | null) => {
|
||||
await nativeRef.current?.setVideoAspectRatio(aspectRatio);
|
||||
},
|
||||
setVideoScaleFactor: async (scaleFactor: number) => {
|
||||
await nativeRef.current?.setVideoScaleFactor(scaleFactor);
|
||||
},
|
||||
}));
|
||||
|
||||
const {
|
||||
|
||||
@@ -82,6 +82,14 @@ class VlcPlayerModule : Module() {
|
||||
AsyncFunction("setSubtitleURL") { view: VlcPlayerView, url: String, name: String ->
|
||||
view.setSubtitleURL(url, name)
|
||||
}
|
||||
|
||||
AsyncFunction("setVideoAspectRatio") { view: VlcPlayerView, aspectRatio: String? ->
|
||||
view.setVideoAspectRatio(aspectRatio)
|
||||
}
|
||||
|
||||
AsyncFunction("setVideoScaleFactor") { view: VlcPlayerView, scaleFactor: Float ->
|
||||
view.setVideoScaleFactor(scaleFactor)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -335,6 +335,16 @@ class VlcPlayerView(context: Context, appContext: AppContext) : ExpoView(context
|
||||
mediaPlayer?.addSlave(IMedia.Slave.Type.Subtitle, Uri.parse(subtitleURL), true)
|
||||
}
|
||||
|
||||
fun setVideoAspectRatio(aspectRatio: String?) {
|
||||
log.debug("Setting video aspect ratio: $aspectRatio")
|
||||
mediaPlayer?.aspectRatio = aspectRatio
|
||||
}
|
||||
|
||||
fun setVideoScaleFactor(scaleFactor: Float) {
|
||||
log.debug("Setting video scale factor: $scaleFactor")
|
||||
mediaPlayer?.scale = scaleFactor
|
||||
}
|
||||
|
||||
private fun setInitialExternalSubtitles() {
|
||||
externalSubtitles?.let { subtitles ->
|
||||
for (subtitle in subtitles) {
|
||||
|
||||
@@ -62,6 +62,14 @@ public class VlcPlayerModule: Module {
|
||||
view.setSubtitleTrack(trackIndex)
|
||||
}
|
||||
|
||||
AsyncFunction("setVideoAspectRatio") { (view: VlcPlayerView, aspectRatio: String?) in
|
||||
view.setVideoAspectRatio(aspectRatio)
|
||||
}
|
||||
|
||||
AsyncFunction("setVideoScaleFactor") { (view: VlcPlayerView, scaleFactor: Float) in
|
||||
view.setVideoScaleFactor(scaleFactor)
|
||||
}
|
||||
|
||||
AsyncFunction("getSubtitleTracks") { (view: VlcPlayerView) -> [[String: Any]]? in
|
||||
return view.getSubtitleTracks()
|
||||
}
|
||||
|
||||
@@ -243,6 +243,26 @@ class VlcPlayerView: ExpoView {
|
||||
return tracks
|
||||
}
|
||||
|
||||
@objc func setVideoAspectRatio(_ aspectRatio: String?) {
|
||||
DispatchQueue.main.async {
|
||||
if let aspectRatio = aspectRatio {
|
||||
// Convert String to C string for VLC
|
||||
let cString = strdup(aspectRatio)
|
||||
self.mediaPlayer?.videoAspectRatio = cString
|
||||
} else {
|
||||
// Reset to default (let VLC determine aspect ratio)
|
||||
self.mediaPlayer?.videoAspectRatio = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@objc func setVideoScaleFactor(_ scaleFactor: Float) {
|
||||
DispatchQueue.main.async {
|
||||
self.mediaPlayer?.scaleFactor = scaleFactor
|
||||
print("Set video scale factor: \(scaleFactor)")
|
||||
}
|
||||
}
|
||||
|
||||
@objc func stop(completion: (() -> Void)? = nil) {
|
||||
guard !isStopping else {
|
||||
completion?()
|
||||
|
||||
Reference in New Issue
Block a user