From bc052b3f2476f6e8b3456031570849621d9c6364 Mon Sep 17 00:00:00 2001 From: callo90 Date: Thu, 13 Jun 2024 17:44:26 -0500 Subject: [PATCH] Added set volume to proxy Removed harcoded validation of 200 in mediaPlayerTimeChanged that caused issues to play videos --- .DS_Store | Bin 0 -> 6148 bytes Example/.DS_Store | Bin 0 -> 6148 bytes Sources/.DS_Store | Bin 0 -> 6148 bytes Sources/VLCUI/.DS_Store | Bin 0 -> 6148 bytes Sources/VLCUI/UIVLCVideoPlayerView.swift | 16 ++-------------- Sources/VLCUI/VLCVideoPlayer/Proxy.swift | 10 ++++++++-- 6 files changed, 10 insertions(+), 16 deletions(-) create mode 100644 .DS_Store create mode 100644 Example/.DS_Store create mode 100644 Sources/.DS_Store create mode 100644 Sources/VLCUI/.DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..c8b7e77f6c14d0bcfcf3c7186ec4ab8bee32c104 GIT binary patch literal 6148 zcmeHKO^ee&7=EX%Hr)^CL18@z0k5TQrLuyTY(EYQDzXthsMMs1HEfzGO}Z6IA$R>R zp8X;EUp(nEAB85Xdvup&UYL32<9%i_&zsC-h=}zTL5HYGL>7|3+77b6nCKVjf>m_O z9*~JKPGUaxWA39a1~g_AFbZ661;n>oqc%+_qOA1&9;2`QTbf+N&c+YE6H18FoWc_4 zTZyv=PD)EKK2nAxI8*Y%IGlFWt<`7HQ9$zZJDtoX7sA?D?;wa5-w;>GLG>q9mM4LKK8>dG{tt z0>13=MG~Zv>#7c`VKqk0d#hEq`>17iI*->ad)4V4J!#oT-OhU5uCwN3L=z(2Mw;= z^s8s>Uip)l2QUg41+JR{Vt=ra1UedXg>vgaCa(a%8k(h{EPwrhwrBu48gqqcfiXn| zDk{@g45n`mOwrNrX#ZTHq7#!dV;ns*(>D~RFCNU6?!+90CN~Ng1&Rt(RkbP3|KY#y z|3#9i83l|2H%b9k8@PiWmZZ#iw0x1^ur3Jkh}gN|A>D_ zXLh%uR6UBy49vdC?7V!ugxw4Ph{~Yl0u%wjK_|@Qarne&o_xwOHj_mZ`W$tr!94_U z3!SNIPW(m%=-tgj0}fyxj^X|Li=kbQ)nyo~5NqfI*+XA@(T34Cyl~j-Sl(0EiKAYB zW8+z5vbmYrIcLr(IOqPg8v6a9Kj>A0?kOD|DHVs4I0ze2d)O>4?yIC9L`l1=2~n$! zC1)p5(o(~U8YHcr=K5yB$vgRGab+|rmp4n&b+^VPIdaR}J0-bYcE{tqv$VRtd)T~* zZxi*P9{~h@xY`yhPT&!PFNL}DyGg8)E3BFDCp<=0fE8c`{(u5@>2eBx;9mI_Spiny zXBD9JL823S7E^A*p^0EjtEYr~j+6^SD)dKOcIID;k(712S5Z>*NO(;SS3VK`cTC|Z!1uwC!hk_@g^`KH4Q#2T}(x&!M3c2eG`69lK z&g^cbQoV^tnSq&aGdq)Hz74w>#u#smLWi*mW6T0Y%-LYR5u8U|keu=40lB(IyB*7$ zAeO;GEIIxs1GsiY)?vr2$<4#TUY*_9Q$c69Ss}3!3AEON*M>UaWCjZ{c*Rl)|5%wi<168B}8E#LN3pvB$VTZ z93|mU<@$QUvMsw?*_=#Vceg4WXKz{+6UVLZS4G`*rc>Km-`Y7i>E6c=iF{Ts%{Y9V zN>&Zd-~|SAB|Z6rB$ml7cxM^2NJ3(O7$63giUG69S>>gwii#lyh=Jc=0QUz0is%{4 zG^(uwjA{V@3*c4)WBhT%9AVHim}!I=5Ux`Jbt*S42G{A}7bea#m}%7MjGN|znXwdxW7>0jC&f%5(C7*R|c^61F7KofAn+zuY$-B1H`~`GQbNhztw=+%-On7C7!hc t^coZe<1&q(DKJn+F~s6gyaB2N`~nAnp218bctGe!K+!;k82D2LJ^-W1RKoxO literal 0 HcmV?d00001 diff --git a/Sources/VLCUI/.DS_Store b/Sources/VLCUI/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..bd943ed94d9f6c4845ba704c62c268cc03404252 GIT binary patch literal 6148 zcmeHK&ui2`6n@jLZni~PP(ceq!0S>QS*hS9Zrek_gP2+mDr;iW8cZ`wk~NlPA$R>> zJo}IMzj)H`%}l}Fx(i-pk$K_G_vXiYnfWF&lOZB87{?w_mxvrFV`~G+AB5{!FUguI zX#<6dkyA-2Nn*5O8L$kjIs?3RH|T&qQALSbw`TnwX7XK>$q4nlIXr=G|5O5t=mtHb zj6!&wV7(V~Mn`l`Bg80a8(L!@IH77T%GbFlTl9hs>6o6<9@3Oz_)8P{9Co2f6GU4W zQ{0`4d3{;D+5U*nf8!g~<;XDdEgEHMS?%n67i;USD_7f2+u3y91n*@XRADtP2VwDw zb4OBU(S;pG$7xazyEpe_UWI9%6v`ou6Eu1KGR037Z^(k`WO^>Ci7FY z;}~1Z$i%csI>o~iwRnPlAkOcf4zgBOfdTW8IGd}`8QTZTfMsB%7~uWEg);gE8;xq~ zK%%Yyz!r*?z~z7?L?#FAa{*S{M2j q%EIj$jmiayIgXXVNAYc_64beD0DXgvMwCG8kAR}VCYFJJ%D^u!+owqY literal 0 HcmV?d00001 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 ///