Seeking around in m3u8 streaming

This forum is about all development around libVLC.
rhaidiz
New Cone
New Cone
Posts: 1
Joined: 17 May 2024 15:54

Seeking around in m3u8 streaming

Postby rhaidiz » 17 May 2024 16:00

Hello all, this is my first time using VLCKit.
I'm doing a few tests to see if I got the gist of integrating it into a SwiftUI app, everything was working smoothly until I stumbled in an issue that for the life of me I cannot fix.
I've done a number of tests with a number of video format, but I've found 2 m3u8 sources that I simply cannot properly play, of better yet I cannot seek.
The two sources are: They are just demo sources that I found around just to test my code.

I've created the simplest possible code to reproduce the issue, here it goes.

Code: Select all

import SwiftUI import VLCKit struct ContentView: View { @StateObject private var viewModel = VideoPlayerViewModel() var body: some View { VStack { VideoPlayerView(player: viewModel.player) .frame(width: 400, height: 300) // Set your desired frame .onAppear { viewModel.setupPlayer() } Slider(value: $viewModel.seekTime, in: 0...viewModel.videoLength, onEditingChanged: { editing in viewModel.seekVideo(to: viewModel.seekTime) }) .padding() } } } class VideoPlayerViewModel: ObservableObject { @Published var player = VLCMediaPlayer() @Published var seekTime: Float = 0 var videoLength: Float { return (player.media?.length.value?.floatValue ?? 0) / 1000 } func setupPlayer() { let media = VLCMedia(url: URL(string: "https://bradmax.com/static/video/tos/440272.m3u8")!) player.media = media player.play() } func seekVideo(to time: Float) { let vlcTime = VLCTime(number: NSNumber(value: time * 1000)) player.time = vlcTime } } struct VideoPlayerView: NSViewRepresentable { let player: VLCMediaPlayer func makeNSView(context: Context) -> NSView { let view = NSView() player.drawable = view return view } func updateNSView(_ nsView: NSView, context: Context) { // Update the view if needed. } }

When I try to move the slider around to change position in the video stream, it doesn't change the position and it starts playing back from where it was.
Sometimes it does change position, but not to where I move the slider, it's all very strange.
I've tested the video stream with VLC 3.0.20 for macOS and I can successfully move around the timeline, which makes me thinking I'm doing something wrong in my code.
I'm using VLCKit 3.5.0.

Any idea what I might be doing wrong?

Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 7 guests