Coder Social home page Coder Social logo

vlcui's Introduction

VLCUI

A VLCKit wrapper for SwiftUI.

Requirements

VLCKit must be installed and added to your project prior to using VLCUI.

Usage

struct ContentView: View {
	var body: some View {
		VLCVideoPlayer(url: /* video url */)
	}
}

Example

An example project is provided to show basic functionality of VLCUI. Download the frameworks with the provided Cartfile:

carthage update --use-xcframeworks

vlcui's People

Contributors

lepips avatar mo7amedfouad avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

vlcui's Issues

Using demo and double playback issue

I am testing your great library out and just looking at the Example app you provide.

I am using tvOS

I noticed that when the app starts, big buck bunny starts to play, then after around 0.2 seconds, it restarts playing again from the beginning.

Is this intentional?

To test out commands, I tried to seek to a starting position of 0.75 (ie, three quarters of the way through) but because of this double playback issue, it's not possible. The first 0.2 seconds of the video has seeked to the required position, but the 2nd start ignores it and starts from 0.

Better Aspect Fill

Currently, VLCVideoPlayer.Event.aspectFill animation is manually controlled.

Replace to be more customizable by removing the manual animation and replace with:

enum Event {
    /// Aspect fill given the percentage between 0...1.0
    case aspectFill(Float)
}

This would set the aspect fill state to a certain progress. This would allow gestures to set the aspect fill based on its percentage completed and the send event can be surrounded by an animation for animations.

Global Renderer

Hi,

I'm trying to add a fullscreen toggle for my player but the problem is that it currently seems to be impossible to re-render the view without resetting the VLCMediaPlayer.

This is because the VLCVideoPlayer always creates a new UIVLCVideoPlayerView view:

public struct VLCVideoPlayer: _PlatformRepresentable {

    private var configuration: VLCVideoPlayer.Configuration
    private var proxy: VLCVideoPlayer.Proxy?
    private var onTicksUpdated: (Int, VLCVideoPlayer.PlaybackInformation) -> Void
    private var onStateUpdated: (VLCVideoPlayer.State, VLCVideoPlayer.PlaybackInformation) -> Void
    private var loggingInfo: (VLCVideoPlayerLogger, LoggingLevel)?

    #if os(macOS)
    public func makeNSView(context: Context) -> UIVLCVideoPlayerView {
        makeVideoPlayerView()
    }

    public func updateNSView(_ nsView: UIVLCVideoPlayerView, context: Context) {}
    #else
    public func makeUIView(context: Context) -> UIVLCVideoPlayerView {
        makeVideoPlayerView()
    }

    public func updateUIView(_ uiView: UIVLCVideoPlayerView, context: Context) {}
    #endif

    private func makeVideoPlayerView() -> UIVLCVideoPlayerView {
        UIVLCVideoPlayerView(
            configuration: configuration,
            proxy: proxy,
            onTicksUpdated: onTicksUpdated,
            onStateUpdated: onStateUpdated,
            loggingInfo: loggingInfo
        )
    }
}

which in turn always creates a new VLCMediaPlayer:

    init(
        configuration: VLCVideoPlayer.Configuration,
        proxy: VLCVideoPlayer.Proxy?,
        onTicksUpdated: @escaping (Int, VLCVideoPlayer.PlaybackInformation) -> Void,
        onStateUpdated: @escaping (VLCVideoPlayer.State, VLCVideoPlayer.PlaybackInformation) -> Void,
        loggingInfo: (VLCVideoPlayerLogger, VLCVideoPlayer.LoggingLevel)?
    ) {
        self.configuration = configuration
        self.proxy = proxy
        self.onTicksUpdated = onTicksUpdated
        self.onStateUpdated = onStateUpdated
        self.loggingInfo = loggingInfo
        super.init(frame: .zero)

        proxy?.videoPlayerView = self

        #if os(macOS)
        layer?.backgroundColor = .clear
        #else
        backgroundColor = .clear
        #endif

        setupVideoContentView()
        setupVLCMediaPlayer(with: configuration)
    }

    func setupVLCMediaPlayer(with newConfiguration: VLCVideoPlayer.Configuration) {
        currentMediaPlayer?.stop()
        currentMediaPlayer = nil

        let media = VLCMedia(url: newConfiguration.url)
        media.addOptions(newConfiguration.options)

        let newMediaPlayer = VLCMediaPlayer()
        newMediaPlayer.media = media
        newMediaPlayer.drawable = videoContentView
        newMediaPlayer.delegate = self

        if let loggingInfo = loggingInfo {
            newMediaPlayer.libraryInstance.debugLogging = true
            newMediaPlayer.libraryInstance.debugLoggingLevel = loggingInfo.level.rawValue.asInt32
            newMediaPlayer.libraryInstance.debugLoggingTarget = self
        }

        for child in newConfiguration.playbackChildren {
            newMediaPlayer.addPlaybackSlave(child.url, type: child.type.asVLCSlaveType, enforce: child.enforce)
        }

        configuration = newConfiguration
        currentMediaPlayer = newMediaPlayer
        proxy?.mediaPlayer = newMediaPlayer
        hasSetCurrentConfigurationValues = false
        lastPlayerTicks = 0
        lastPlayerState = .opening

        if newConfiguration.autoPlay {
            newMediaPlayer.play()
        }
    }

Would it be possible to change this behaviour to work more like SwiftUI's video player, which creates a new VideoPlayer view that references an existing AVPlayer? This would make implementing such use cases a lot more convenient.

Replay Configuration

For replay the current configuration is used but with the start ticks set to 0 and auto play enabled. The configuration contextually represents the values of how the current media started.

Add an additional alteredConfiguration property that has the current player-state values like subtitle index, playback children, etc. and is rotated to that configuration on replay.

`jumpForward/jumpBackward` Custom Handling

When using jumpFoward/jumpBackward with a length that would put VLCMediaPlayer out of bounds of the media it puts it into an untrackable state. Check when using these events against the ticks/seconds to put VLCVideoPlayer into a custom and friendly state.

setAudioTrack bug

hello

setAudioTrack function not working because it triggers the function to change subtitles

Proxy.swift line number 76

plaese replace currentVideoSubTitleIndex with currentAudioTrackIndex

Random round Play/Stop button is incredibly ambiguous as to what it does

I've encountered this button on both tvOS and iOS with Swiftfin, and i'm incredibly confused as to what it means.

I assume it means autoplay? If so, please use a more specific icon for it (such as repeat.circle and repeat.circle.fill), since pressing it doesn't do anything but toggling it, and there's no indication of what it's supposed to do.

Playback state not updating on play/pause

Hi,

Using: tvOSVLCUI example

I can play the videos fine but when i press play/pause it doesnt update viewModel.playerState in OverlayView, the others one like viewModel.position does, but not playerState.

Implement `advanceNextFrame`

Add VLCVideoPlayer.Event.advanceNextFrame which calls VLCMediaPlayer.gotoNextFrame() along with documentation that it will stop playback and put it into a certain state.

Swipe Up/Down etc

Thanks for making this, it's great.

One thing I think is missing, and I don't know if you intend to add it or not, is to be able to Swipe Up/Down/Left/Right to display some sort of view.

For example, Swipe Down to show an information panel about the currently playing video. fully interactive panel so you can change settings etc. Just the mechanics to display the panel would be ideal. how it looks down to the developer. Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.