Skip to content

Commit

Permalink
feat: forward、backward
Browse files Browse the repository at this point in the history
  • Loading branch information
isslayne committed Aug 13, 2021
1 parent cf6e781 commit dcd3843
Show file tree
Hide file tree
Showing 9 changed files with 243 additions and 26 deletions.
38 changes: 27 additions & 11 deletions Resources/TVVLCPlayer.storyboard
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder.AppleTV.Storyboard" version="3.0" toolsVersion="18122" targetRuntime="AppleTV" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="WfO-Rv-1Kc">
<document type="com.apple.InterfaceBuilder.AppleTV.Storyboard" version="3.0" toolsVersion="19158" targetRuntime="AppleTV" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="WfO-Rv-1Kc">
<device id="appleTV" appearance="light"/>
<dependencies>
<deployment identifier="tvOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18093"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19141"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand Down Expand Up @@ -161,12 +161,16 @@
<outletCollection property="gestureRecognizers" destination="dPw-kB-jYe" appends="YES" id="9IQ-JE-gXO"/>
<outletCollection property="gestureRecognizers" destination="evZ-3a-6GS" appends="YES" id="Czi-me-D1K"/>
<outletCollection property="gestureRecognizers" destination="KfI-P8-zeZ" appends="YES" id="lmc-Dk-Ai7"/>
<outletCollection property="gestureRecognizers" destination="hrX-2D-Mh3" appends="YES" id="oyf-f0-2eo"/>
<outletCollection property="gestureRecognizers" destination="MhL-Yi-dbj" appends="YES" id="PTC-Iq-qkD"/>
</connections>
</view>
<connections>
<outlet property="actionGesture" destination="evZ-3a-6GS" id="6Ic-aU-aEY"/>
<outlet property="bufferingIndicator" destination="Sti-Nb-A6T" id="tJ8-dQ-xfp"/>
<outlet property="cancelGesture" destination="Mao-0Z-rHK" id="aPU-aE-6Pt"/>
<outlet property="jumpBackwardGesture" destination="MhL-Yi-dbj" id="bSL-4y-Asv"/>
<outlet property="jumpForwardGesture" destination="hrX-2D-Mh3" id="L0x-ZT-RXw"/>
<outlet property="openingIndicator" destination="Qfy-C8-dbo" id="e4S-1Y-cQm"/>
<outlet property="playPauseGesture" destination="dPw-kB-jYe" id="GsZ-aM-I8C"/>
<outlet property="playbackControlView" destination="n9n-u4-Sme" id="Ebc-ib-gIp"/>
Expand Down Expand Up @@ -224,6 +228,18 @@
<outlet property="delegate" destination="WfO-Rv-1Kc" id="XAp-vi-kOj"/>
</connections>
</swipeGestureRecognizer>
<tapGestureRecognizer id="hrX-2D-Mh3">
<pressTypeMask key="allowedPressTypes" rightArrow="YES"/>
<connections>
<action selector="jumpForward:" destination="WfO-Rv-1Kc" id="hEV-yz-Haj"/>
</connections>
</tapGestureRecognizer>
<tapGestureRecognizer id="MhL-Yi-dbj">
<pressTypeMask key="allowedPressTypes" leftArrow="YES"/>
<connections>
<action selector="jumpBackward:" destination="WfO-Rv-1Kc" id="B9r-OA-pHo"/>
</connections>
</tapGestureRecognizer>
<tapGestureRecognizer enabled="NO" id="Mao-0Z-rHK">
<pressTypeMask key="allowedPressTypes" menu="YES"/>
<connections>
Expand All @@ -242,18 +258,18 @@
<viewControllerLayoutGuide type="bottom" id="Y94-dP-KPg"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="Yx4-AL-RRh">
<rect key="frame" x="0.0" y="0.0" width="200" height="275"/>
<rect key="frame" x="0.0" y="0.0" width="400" height="275"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" contentInsetAdjustmentBehavior="scrollableAxes" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="37" sectionHeaderHeight="1" sectionFooterHeight="1" translatesAutoresizingMaskIntoConstraints="NO" id="Ud2-W6-VYu">
<rect key="frame" x="0.0" y="60" width="200" height="215"/>
<rect key="frame" x="0.0" y="60" width="400" height="215"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<prototypes>
<tableViewCell contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="-1" reuseIdentifier="cell" focusStyle="custom" id="0ug-bR-MBf" customClass="SelectableTableViewCell" customModule="TVVLCPlayer" customModuleProvider="target">
<rect key="frame" x="80" y="1" width="120" height="37"/>
<rect key="frame" x="80" y="1" width="320" height="37"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="0ug-bR-MBf" id="Kbf-ee-W10">
<rect key="frame" x="0.0" y="0.0" width="120" height="37"/>
<rect key="frame" x="0.0" y="0.0" width="320" height="37"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="Checkmark" translatesAutoresizingMaskIntoConstraints="NO" id="Ua7-4T-kGe">
Expand All @@ -265,7 +281,7 @@
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="0KT-Tf-4Eh">
<rect key="frame" x="32" y="0.0" width="88" height="37"/>
<rect key="frame" x="32" y="0.0" width="288" height="37"/>
<fontDescription key="fontDescription" type="system" weight="medium" pointSize="31"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
Expand Down Expand Up @@ -592,7 +608,7 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" alignment="top" spacing="40" translatesAutoresizingMaskIntoConstraints="NO" id="yh0-je-eeT">
<rect key="frame" x="380" y="20" width="1380" height="160"/>
<rect key="frame" x="380" y="20" width="1300" height="160"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="lFK-vf-c27">
<rect key="frame" x="0.0" y="0.0" width="140" height="160"/>
Expand All @@ -601,7 +617,7 @@
</constraints>
</imageView>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" alignment="top" translatesAutoresizingMaskIntoConstraints="NO" id="rZk-E9-UOd">
<rect key="frame" x="180" y="0.0" width="1200" height="141.5"/>
<rect key="frame" x="180" y="0.0" width="1120" height="141.5"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="aVc-LI-tUH">
<rect key="frame" x="0.0" y="0.0" width="69" height="34"/>
Expand Down Expand Up @@ -659,7 +675,7 @@
<constraints>
<constraint firstAttribute="bottom" secondItem="yh0-je-eeT" secondAttribute="bottom" constant="20" id="4UW-Bb-MNh"/>
<constraint firstItem="yh0-je-eeT" firstAttribute="top" secondItem="p6p-6S-Zhe" secondAttribute="top" constant="20" id="88Q-lw-J7i"/>
<constraint firstItem="T83-HO-0be" firstAttribute="trailing" secondItem="yh0-je-eeT" secondAttribute="trailing" id="asl-Oc-qtI"/>
<constraint firstItem="T83-HO-0be" firstAttribute="trailing" secondItem="yh0-je-eeT" secondAttribute="trailing" constant="80" id="asl-Oc-qtI"/>
<constraint firstItem="yh0-je-eeT" firstAttribute="leading" secondItem="T83-HO-0be" secondAttribute="leading" constant="300" id="dNB-Dw-fNn"/>
</constraints>
</view>
Expand All @@ -684,7 +700,7 @@
</scene>
</scenes>
<inferredMetricsTieBreakers>
<segue reference="9k5-QU-jJo"/>
<segue reference="gcE-xp-zqO"/>
</inferredMetricsTieBreakers>
<resources>
<image name="Checkmark" width="21" height="20"/>
Expand Down
8 changes: 6 additions & 2 deletions Sources/Panel/InfoViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,13 @@ class InfoViewController: UIViewController {
func configureTitle() {
let mediaDict = player.media?.metaDictionary
if let title = mediaDict?[VLCMetaInformationTitle] as? String {
titleLabel.text = title
titleLabel.text = title
// titleLabel.numberOfLines = 0
titleLabel.lineBreakMode = NSLineBreakMode.byCharWrapping
} else {
titleLabel.text = player.media?.url.absoluteString
titleLabel.text = player.media?.url.absoluteString
// titleLabel.numberOfLines = 0
titleLabel.lineBreakMode = NSLineBreakMode.byCharWrapping
}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Panel/SlideAnimatedTransitioner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class SlideUpAnimatedTransitioner: NSObject, UIViewControllerAnimatedTransitioni
delay: 0.0, usingSpringWithDamping: 1.0,
initialSpringVelocity: 0.0,
options: .allowUserInteraction,
animations: { secondVCView.frame.origin.y = -secondVC.preferredContentSize.height },
animations: { secondVCView.frame.origin.y = -secondVC.preferredContentSize.height - 60 },
completion: { _ in
secondVCView.removeFromSuperview()
transitionContext.completeTransition(!transitionContext.transitionWasCancelled)})
Expand Down
9 changes: 9 additions & 0 deletions Sources/VLCPlayerViewController.swift
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public class VLCPlayerViewController: UIViewController {
@IBOutlet var actionGesture: LongPressGestureRecogniser!
@IBOutlet var playPauseGesture: UITapGestureRecognizer!
@IBOutlet var cancelGesture: UITapGestureRecognizer!
@IBOutlet var jumpForwardGesture: UITapGestureRecognizer!
@IBOutlet var jumpBackwardGesture: UITapGestureRecognizer!

@IBOutlet var scrubbingPositionController: ScrubbingPositionController!
@IBOutlet var remoteActionPositionController: RemoteActionPositionController!
Expand Down Expand Up @@ -208,6 +210,13 @@ public class VLCPlayerViewController: UIViewController {
player.play()
hideControl()
}
@IBAction func jumpForward(_ sender: Any) {
player.shortJumpForward()
}
@IBAction func jumpBackward(_ sender: Any) {
player.shortJumpBackward()
}

}

// MARK: - Update views
Expand Down
4 changes: 3 additions & 1 deletion SwiftUIDemo/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ struct TestTVVLCPlayerController: UIViewControllerRepresentable {
let player = VLCMediaPlayer()
let media: VLCMedia = VLCMedia(url: URL(string: "https://upload.wikimedia.org/wikipedia/commons/8/88/Big_Buck_Bunny_alt.webm")!)
media.addOption(":http-user-agent=AppleCoreMedia/1.0.0.18L191 (Apple TV; U; CPU OS 14_5 like Mac OS X; zh_cn)")
// player.addPlaybackSlave(URL(string: "http://raw.githubusercontent.com/chinanf-boy/translate-srt/master/test.zh.srt")!, type: .subtitle, enforce: true)
player.addPlaybackSlave(URL(string: "http://raw.githubusercontent.com/chinanf-boy/translate-srt/master/test.zh.srt"), type: .subtitle, enforce: true)
player.media = media
let playerViewController = VLCPlayerViewController.instantiate(player: player)
return playerViewController
Expand All @@ -25,7 +27,7 @@ struct TestTVVLCPlayerController: UIViewControllerRepresentable {
}
}

struct TestPlayerView: View {
struct TestPlayerView: View {
var body: some View {
TestTVVLCPlayerController()
.edgesIgnoringSafeArea(/*@START_MENU_TOKEN@*/.all/*@END_MENU_TOKEN@*/)
Expand Down
5 changes: 5 additions & 0 deletions SwiftUIDemo/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
<array>
<string>arm64</string>
</array>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>UIUserInterfaceStyle</key>
<string>Automatic</string>
</dict>
Expand Down
Binary file not shown.
Loading

0 comments on commit dcd3843

Please sign in to comment.