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

Best way to get media informations. #529

Closed
loicleser opened this issue Aug 24, 2023 · 5 comments
Closed

Best way to get media informations. #529

loicleser opened this issue Aug 24, 2023 · 5 comments

Comments

@loicleser
Copy link

Hello
I start again to integrate KSPlayer in my application.

What is the best way to retrieve movie information to create a custom interface?

I need to retrieve the following information:
Total time
Remaining time
Current Time / Position

I don't see an easy way to retrieve this information so I guess I'm missing the solution.

Currently I seated a customPlayer that works when I set a ressource.

THANKS

@kingslay
Copy link
Owner

currentTime
totalTime

public protocol KSPlayerLayerDelegate: AnyObject {
    func player(layer: KSPlayerLayer, state: KSPlayerState)
    func player(layer: KSPlayerLayer, currentTime: TimeInterval, totalTime: TimeInterval)
    func player(layer: KSPlayerLayer, finish error: Error?)
    func player(layer: KSPlayerLayer, bufferedCount: Int, consumeTime: TimeInterval)
}

@loicleser
Copy link
Author

No way to do it like on VLC? :

func totalTimeFormatted() -> String {
if currentPlayerEngine == .FFMPEG {
// Need KSTotalTime here
return ksPlayerView...
} else {
return VLCplayer.media?.length.stringValue ?? "00:00"
}
}

@kingslay
Copy link
Owner

duration Total time
currentPlaybackTime


public protocol MediaPlayback: AnyObject {
    var duration: TimeInterval { get }
    var naturalSize: CGSize { get }
    var currentPlaybackTime: TimeInterval { get }
    func prepareToPlay()
    func shutdown()
    func seek(time: TimeInterval, completion: @escaping ((Bool) -> Void))
}

@loicleser
Copy link
Author

Sorry but I don't know how I can use it from the ksPlayerView var I've :-D

@kingslay
Copy link
Owner

你可以看我的demo
也可以搜索下currentPlaybackTime 这个关键字。看下要怎么用。

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

2 participants