Skip to content
This repository has been archived by the owner on Jan 16, 2023. It is now read-only.

Commit

Permalink
Merge branch 'release/0.6.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
Nabil Safatli committed Aug 22, 2017
2 parents 60d715a + 6d441d5 commit 288b19f
Show file tree
Hide file tree
Showing 8 changed files with 172 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Clappr.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "Clappr"
s.version = "0.6.5"
s.version = "0.6.6"
s.summary = "An extensible media player for iOS"
s.homepage = "http://clappr.io"
s.license = 'MIT'
Expand Down
18 changes: 18 additions & 0 deletions Clappr.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@
96D362EE1D41339400CCB866 /* MediaControlView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 96D362C11D41339400CCB866 /* MediaControlView.xib */; };
96D362F11D41345E00CCB866 /* Kingfisher.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96D362F01D41345E00CCB866 /* Kingfisher.framework */; };
96E7D2741E786FEE0056F358 /* InternalEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96E7D2731E786FEE0056F358 /* InternalEvent.swift */; };
9E3F43F91F3102D800417919 /* AppStateManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E3F43F81F3102D800417919 /* AppStateManager.swift */; };
9E3F43FC1F31116100417919 /* AppStateManagerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E3F43FA1F3102E900417919 /* AppStateManagerTests.swift */; };
B46D05AA1DB7DE4B0004B23F /* Quick.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B46D05A71DB7DBD60004B23F /* Quick.framework */; };
B46D05AB1DB7DE570004B23F /* Nimble.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B46D05A51DB7DBC50004B23F /* Nimble.framework */; };
B4D817701E8ADCE600DC07AE /* Kingfisher.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96D362F01D41345E00CCB866 /* Kingfisher.framework */; };
Expand Down Expand Up @@ -175,6 +177,8 @@
96D362C11D41339400CCB866 /* MediaControlView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MediaControlView.xib; sourceTree = "<group>"; };
96D362F01D41345E00CCB866 /* Kingfisher.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Kingfisher.framework; path = Carthage/Build/iOS/Kingfisher.framework; sourceTree = "<group>"; };
96E7D2731E786FEE0056F358 /* InternalEvent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InternalEvent.swift; sourceTree = "<group>"; };
9E3F43F81F3102D800417919 /* AppStateManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppStateManager.swift; sourceTree = "<group>"; };
9E3F43FA1F3102E900417919 /* AppStateManagerTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppStateManagerTests.swift; sourceTree = "<group>"; };
B46D05A51DB7DBC50004B23F /* Nimble.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Nimble.framework; path = Carthage/Build/iOS/Nimble.framework; sourceTree = "<group>"; };
B46D05A71DB7DBD60004B23F /* Quick.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Quick.framework; path = Carthage/Build/iOS/Quick.framework; sourceTree = "<group>"; };
D105480873032552EC2B57ED /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; };
Expand Down Expand Up @@ -223,7 +227,9 @@
607FACD11AFB9204008FA782 /* Products */,
D9A0DBC9D3DEA84C86432E68 /* Frameworks */,
);
indentWidth = 4;
sourceTree = "<group>";
tabWidth = 4;
};
607FACD11AFB9204008FA782 /* Products */ = {
isa = PBXGroup;
Expand All @@ -242,6 +248,7 @@
969703A51BEA8C7500B7F282 /* BaseObjectTests.swift */,
96664E6B1BF209CB00095E6E /* ContainerTests.swift */,
96A979861BFF964C00E5EA01 /* CoreTests.swift */,
9E3F43FA1F3102E900417919 /* AppStateManagerTests.swift */,
96A9797C1BFE2BCC00E5EA01 /* DateFormatterTests.swift */,
9697039F1BEA716100B7F282 /* EventHandlerTests.swift */,
96A9CE371C97387000C21E80 /* LoaderTests.swift */,
Expand Down Expand Up @@ -312,6 +319,7 @@
96D362891D41339400CCB866 /* Classes */ = {
isa = PBXGroup;
children = (
9E3F43F21F30F89D00417919 /* Helper */,
968E5BD71D6CBF970092F372 /* Log */,
96D3628B1D41339400CCB866 /* Base */,
96D362981D41339400CCB866 /* Enum */,
Expand Down Expand Up @@ -457,6 +465,14 @@
name = Header;
sourceTree = "<group>";
};
9E3F43F21F30F89D00417919 /* Helper */ = {
isa = PBXGroup;
children = (
9E3F43F81F3102D800417919 /* AppStateManager.swift */,
);
path = Helper;
sourceTree = "<group>";
};
D9A0DBC9D3DEA84C86432E68 /* Frameworks */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -683,6 +699,7 @@
96664E5E1BF0D5FB00095E6E /* PlaybackTests.swift in Sources */,
9684B6CA1D186E4700D012C2 /* AVFoundationPlaybackTests.swift in Sources */,
96A9CE391C973A0600C21E80 /* LoaderTests.swift in Sources */,
9E3F43FC1F31116100417919 /* AppStateManagerTests.swift in Sources */,
EDF652241D46829100627C48 /* UIContainerPluginTests.swift in Sources */,
96912C3E1C21A1AF003A4AFD /* PosterPluginTests.swift in Sources */,
96B4656B1BF6028A0025975A /* UIPluginTests.swift in Sources */,
Expand Down Expand Up @@ -720,6 +737,7 @@
968E5BDB1D6CC0680092F372 /* LogLevel.swift in Sources */,
96D362C61D41339400CCB866 /* Core.swift in Sources */,
96D362C71D41339400CCB866 /* EventHandler.swift in Sources */,
9E3F43F91F3102D800417919 /* AppStateManager.swift in Sources */,
96D362E71D41339400CCB866 /* Plugin.swift in Sources */,
96D362D81D41339400CCB866 /* PluginType.swift in Sources */,
96D362C91D41339400CCB866 /* Loader.swift in Sources */,
Expand Down
15 changes: 15 additions & 0 deletions Clappr/Classes/Base/MediaControl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -377,14 +377,29 @@ open class MediaControl: UIBaseObject {
case .began:
isSeeking = true
hideControlsTimer?.invalidate()
toggleScrollEnable(in: view, to: false)
case .ended:
container?.playback?.seek(secondsRelativeToPoint(touchPoint))
isSeeking = false
scheduleTimerToHideControls()
toggleScrollEnable(in: view, to: true)
default: break
}
}
}

//This function was necessary because our apps were using the player inside
//a scrollview, so a conflict was happening between the swipe event in the
//slider and the scrollview.
private func toggleScrollEnable(in view: UIView?,to isEnabled: Bool) {
guard let view = view else {
return
}
if let scrollView = view as? UIScrollView {
scrollView.isScrollEnabled = isEnabled
}
toggleScrollEnable(in: view.superview, to: isEnabled)
}

open func secondsRelativeToPoint(_ touchPoint: CGPoint) -> Double {
if let seekBarView = self.seekBarView,
Expand Down
34 changes: 34 additions & 0 deletions Clappr/Classes/Helper/AppStateManager.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import Foundation

protocol AppStateManagerDelegate: class {
func didChange(state: UIApplicationState)
}

class AppStateManager: NSObject {

private weak var delegate: AppStateManagerDelegate?

@discardableResult
init(delegate: AppStateManagerDelegate) {
self.delegate = delegate
super.init()
}

deinit {
stopMonitoring()
}

func startMonitoring() {
NotificationCenter.default.addObserver(self, selector: #selector(didChangeState), name: Notification.Name.UIApplicationDidBecomeActive, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(didChangeState), name: Notification.Name.UIApplicationDidEnterBackground, object: nil)
}

func stopMonitoring() {
NotificationCenter.default.removeObserver(self, name: Notification.Name.UIApplicationDidBecomeActive, object: nil)
NotificationCenter.default.removeObserver(self, name: Notification.Name.UIApplicationDidEnterBackground, object: nil)
}

@objc private func didChangeState() {
delegate?.didChange(state: UIApplication.shared.applicationState)
}
}
2 changes: 1 addition & 1 deletion Clappr/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.6.4</string>
<string>0.6.6</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
70 changes: 62 additions & 8 deletions Example/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,11 +1,65 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15E65" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="vXZ-lx-hvc">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12121" systemVersion="16G29" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="X5F-KS-Cdq">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Navigation Controller-->
<scene sceneID="HtZ-7p-yBV">
<objects>
<navigationController id="X5F-KS-Cdq" sceneMemberID="viewController">
<navigationBar key="navigationBar" contentMode="scaleToFill" id="lV7-k1-Jii">
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<connections>
<segue destination="b2n-EE-xfA" kind="relationship" relationship="rootViewController" id="YMR-0i-ocL"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dhI-S7-fah" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-1314" y="247"/>
</scene>
<!--View Controller-->
<scene sceneID="5X2-nt-SO7">
<objects>
<viewController id="b2n-EE-xfA" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="mZa-R5-Qwk"/>
<viewControllerLayoutGuide type="bottom" id="2pD-ht-Ixh"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="KNV-CV-WeC">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="tY3-dQ-IX8">
<rect key="frame" x="149" y="318" width="77" height="30"/>
<state key="normal" title="Start Video"/>
<connections>
<segue destination="vXZ-lx-hvc" kind="show" id="Tab-hp-Thc"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="tY3-dQ-IX8" firstAttribute="top" secondItem="mZa-R5-Qwk" secondAttribute="bottom" constant="254" id="D4y-sE-bhq"/>
<constraint firstItem="2pD-ht-Ixh" firstAttribute="top" secondItem="tY3-dQ-IX8" secondAttribute="bottom" constant="319" id="EyJ-qr-RV6"/>
<constraint firstAttribute="trailingMargin" secondItem="tY3-dQ-IX8" secondAttribute="trailing" constant="133" id="Yng-hp-jaA"/>
<constraint firstItem="tY3-dQ-IX8" firstAttribute="leading" secondItem="KNV-CV-WeC" secondAttribute="leadingMargin" constant="133" id="vGF-mn-fFH"/>
</constraints>
</view>
<navigationItem key="navigationItem" id="2H6-cX-44I"/>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="8EC-n9-cHB" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-487" y="247"/>
</scene>
<!--View Controller-->
<scene sceneID="ufC-wZ-h7g">
<objects>
Expand All @@ -15,12 +69,12 @@
<viewControllerLayoutGuide type="bottom" id="2fi-mo-0CV"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="kh9-bI-dsS">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="5zE-hA-IRs" userLabel="Player Container">
<rect key="frame" x="0.0" y="40" width="600" height="310"/>
<color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
<rect key="frame" x="-4" y="40" width="383" height="377"/>
<color key="backgroundColor" red="0.66666666666666663" green="0.66666666666666663" blue="0.66666666666666663" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="200" id="30R-xP-Ym2"/>
</constraints>
Expand All @@ -31,7 +85,7 @@
</variation>
</view>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="5zE-hA-IRs" firstAttribute="top" secondItem="jyV-Pf-zRb" secondAttribute="bottom" constant="20" id="2V5-15-1vR"/>
<constraint firstItem="2fi-mo-0CV" firstAttribute="top" secondItem="5zE-hA-IRs" secondAttribute="bottom" constant="250" id="ULG-ic-dbv"/>
Expand All @@ -45,7 +99,7 @@
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="x5A-6p-PRh" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="274" y="265"/>
<point key="canvasLocation" x="498" y="247"/>
</scene>
</scenes>
</document>
4 changes: 4 additions & 0 deletions Example/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ class ViewController: UIViewController {

}

override func viewWillDisappear(_ animated: Bool) {
player.destroy()
}

override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
return UIInterfaceOrientationMask.portrait
}
Expand Down
37 changes: 37 additions & 0 deletions Tests/AppStateManagerTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import XCTest

@testable import Clappr

class FakeAppStateHandler: AppStateManagerDelegate {
var state: UIApplicationState?
let expectation: XCTestExpectation

init(expectation: XCTestExpectation) {
self.expectation = expectation
}

func didChange(state: UIApplicationState) {
self.state = state
expectation.fulfill()
}
}

class AppStateManagerTests: XCTestCase {

@available(iOS 9.0, *)
func testAppDidEnterInBackground() {
let expect = expectation(description: "Wait for app enter in background")
let fakeHandler = FakeAppStateHandler(expectation: expect)
let stateManagerDelegate = AppStateManager(delegate: fakeHandler)
stateManagerDelegate.startMonitoring()

XCUIDevice.shared().press(XCUIDeviceButton.home)

waitForExpectations(timeout: 20) { error in
if error != nil {
XCTFail()
}
XCTAssertEqual(fakeHandler.state?.rawValue, UIApplicationState.background.rawValue)
}
}
}

0 comments on commit 288b19f

Please sign in to comment.