diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..c8b7e77 Binary files /dev/null and b/.DS_Store differ diff --git a/Example/.DS_Store b/Example/.DS_Store new file mode 100644 index 0000000..99bcd5d Binary files /dev/null and b/Example/.DS_Store differ diff --git a/Sources/.DS_Store b/Sources/.DS_Store new file mode 100644 index 0000000..04b7052 Binary files /dev/null and b/Sources/.DS_Store differ diff --git a/Sources/VLCUI/.DS_Store b/Sources/VLCUI/.DS_Store new file mode 100644 index 0000000..bd943ed Binary files /dev/null and b/Sources/VLCUI/.DS_Store differ diff --git a/Sources/VLCUI/UIVLCVideoPlayerView.swift b/Sources/VLCUI/UIVLCVideoPlayerView.swift index f446ad1..32a4f90 100644 --- a/Sources/VLCUI/UIVLCVideoPlayerView.swift +++ b/Sources/VLCUI/UIVLCVideoPlayerView.swift @@ -196,13 +196,10 @@ extension UIVLCVideoPlayerView: VLCMediaPlayerDelegate { onTicksUpdated(currentTicks.asInt, playbackInformation) // Set playing state - if lastPlayerState != .playing, - abs(currentTicks - lastPlayerTicks) >= 200 - { + if lastPlayerState != .playing, abs(currentTicks - lastPlayerTicks) >= 0 { onStateUpdated(.playing, playbackInformation) lastPlayerState = .playing lastPlayerTicks = currentTicks - if !hasSetCurrentConfigurationValues { setConfigurationValues(with: player, from: configuration) hasSetCurrentConfigurationValues = true @@ -212,8 +209,7 @@ extension UIVLCVideoPlayerView: VLCMediaPlayerDelegate { // Replay if configuration.replay, lastPlayerState == .playing, - abs(player.media!.length.intValue - currentTicks) <= 500 - { + abs(player.media!.length.intValue - currentTicks) <= 500 { configuration.autoPlay = true configuration.startTime = .ticks(0) setupVLCMediaPlayer(with: configuration) @@ -223,33 +219,25 @@ extension UIVLCVideoPlayerView: VLCMediaPlayerDelegate { public func mediaPlayerStateChanged(_ aNotification: Notification) { let player = aNotification.object as! VLCMediaPlayer guard player.state != .playing, player.state != lastPlayerState else { return } - let wrappedState = VLCVideoPlayer.State(rawValue: player.state.rawValue) ?? .error let playbackInformation = constructPlaybackInformation(player: player, media: player.media!) - onStateUpdated(wrappedState, playbackInformation) lastPlayerState = player.state } private func setConfigurationValues(with player: VLCMediaPlayer, from configuration: VLCVideoPlayer.Configuration) { - player.time = VLCTime(int: configuration.startTime.asTicks.asInt32) - let defaultPlayerSpeed = player.rate(from: configuration.rate) player.fastForward(atRate: defaultPlayerSpeed) - if configuration.aspectFill { videoContentView.scale(x: aspectFillScale, y: aspectFillScale) } else { videoContentView.apply(transform: .identity) } - let defaultSubtitleTrackIndex = player.subtitleTrackIndex(from: configuration.subtitleIndex) player.currentVideoSubTitleIndex = defaultSubtitleTrackIndex.asInt32 - let defaultAudioTrackIndex = player.audioTrackIndex(from: configuration.audioIndex) player.currentAudioTrackIndex = defaultAudioTrackIndex.asInt32 - player.setSubtitleSize(configuration.subtitleSize) player.setSubtitleFont(configuration.subtitleFont) player.setSubtitleColor(configuration.subtitleColor) diff --git a/Sources/VLCUI/VLCVideoPlayer/Proxy.swift b/Sources/VLCUI/VLCVideoPlayer/Proxy.swift index 5cf105f..ae73c54 100644 --- a/Sources/VLCUI/VLCVideoPlayer/Proxy.swift +++ b/Sources/VLCUI/VLCVideoPlayer/Proxy.swift @@ -20,7 +20,7 @@ public extension VLCVideoPlayer { weak var mediaPlayer: VLCMediaPlayer? weak var videoPlayerView: UIVLCVideoPlayerView? - + public init() { self.mediaPlayer = nil self.videoPlayerView = nil @@ -94,7 +94,13 @@ public extension VLCVideoPlayer { let newRate = mediaPlayer.rate(from: rate) mediaPlayer.fastForward(atRate: newRate) } - + + /// Set the player volume + public func setVolume(_ volume: Int32) { + guard let mediaPlayer = mediaPlayer else { return } + mediaPlayer.audio?.volume = volume + } + /// Aspect fill depending on the video's content size and the view's bounds, based /// on the given percentage of completion ///