Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes, improvements and Demo project #32

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
5d067d8
fixed album image not being set on launch.
denysco Feb 23, 2018
63242a3
changed contentMode from scaleAspectFit scaleAspectFill to make image…
denysco Feb 23, 2018
475b92d
Fixed retain cycled delegate in PlayerSlider
Apr 5, 2018
56b2cb4
Fixed retain cycle inside PandoraPlayer prefetchItems method
Apr 5, 2018
f64030c
CenterCellCollectionViewLayout targetColumn now computed properly
Apr 5, 2018
48f9b7f
Merge pull request #1 from denysco/master
rivera-ernesto Dec 21, 2018
35adcc3
Merge pull request #2 from Adiletkozha/Ad_fix_branch
rivera-ernesto Dec 21, 2018
a125488
Add .gitignore
rivera-ernesto Dec 21, 2018
88d8ae3
Update podspec
rivera-ernesto Dec 21, 2018
3d507f7
Update to Swift 4.2
rivera-ernesto Dec 21, 2018
76aafbc
Fix deprecation warnings
rivera-ernesto Dec 21, 2018
3ebd55d
Add static_framework to podspec to fix Target has transitive dependen…
rivera-ernesto Dec 21, 2018
ec5c3cf
Fix deprecation warnings
rivera-ernesto Jan 9, 2019
f08e1b9
Update project
rivera-ernesto Jan 9, 2019
1e85fa9
Fix Storyboard’s module
rivera-ernesto Jan 9, 2019
50fd692
Bring close button on top of title label
rivera-ernesto Jan 9, 2019
8d2bfee
Make sure to load views first on configurePlayer() to prevent unwrap …
rivera-ernesto Jan 9, 2019
043d99c
Allow initializing player with no playback items
rivera-ernesto Jan 9, 2019
b88e282
Remove never used AppIcon asset
rivera-ernesto Jan 9, 2019
da615c3
Fix Xib file
rivera-ernesto Jan 9, 2019
9f25824
Fix project SWIFT_VERSION to 4.2
rivera-ernesto Jul 2, 2020
efe7741
Add demo project
rivera-ernesto Jul 2, 2020
f4ff979
Fix build warnings
rivera-ernesto Jul 2, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.DS_Store
xcuserdata
Demo/Pods
425 changes: 425 additions & 0 deletions Demo/Demo.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http:https://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
10 changes: 10 additions & 0 deletions Demo/Demo.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Demo/Demo.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http:https://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
28 changes: 28 additions & 0 deletions Demo/Demo/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// AppDelegate.swift
// Demo
//
// Created by Ernesto Rivera on 7/2/20.
// Copyright © 2020 Applikey Solutions. All rights reserved.
//

import UIKit
import PandoraPlayer

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate
{
var window: UIWindow?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool
{
let player = PandoraPlayer.configure(withPaths: ["RAINDOWN_15", "pop"])
self.window = UIWindow()
self.window?.rootViewController = player
self.window?.makeKeyAndVisible()

return true
}

}

25 changes: 25 additions & 0 deletions Demo/Demo/Base.lproj/LaunchScreen.storyboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
</document>
53 changes: 53 additions & 0 deletions Demo/Demo/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http:https://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UIStatusBarTintParameters</key>
<dict>
<key>UINavigationBar</key>
<dict>
<key>Style</key>
<string>UIBarStyleDefault</string>
<key>Translucent</key>
<false/>
</dict>
</dict>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
Binary file added Demo/Demo/RAINDOWN_15.mp3
Binary file not shown.
Binary file added Demo/Demo/pickup_star.mp3
Binary file not shown.
Binary file added Demo/Demo/pop.mp3
Binary file not shown.
Binary file added Demo/Demo/pop_9cb0d.mp3
Binary file not shown.
Binary file added Demo/Demo/pop_v2.mp3
Binary file not shown.
Binary file added Demo/Demo/they_joined_call_9cb0d.mp3
Binary file not shown.
Binary file added Demo/Demo/they_joined_call_v2.mp3
Binary file not shown.
Binary file added Demo/Demo/they_left_call_9cb0d.mp3
Binary file not shown.
Binary file added Demo/Demo/they_left_call_v2.mp3
Binary file not shown.
9 changes: 9 additions & 0 deletions Demo/Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

platform :ios, '9.0'
use_frameworks!

target 'Demo' do

pod 'PandoraPlayer', :path => '..'

end
28 changes: 28 additions & 0 deletions Demo/Podfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
PODS:
- AudioKit (4.10.1):
- AudioKit/Core (= 4.10.1)
- AudioKit/UI (= 4.10.1)
- AudioKit/Core (4.10.1)
- AudioKit/UI (4.10.1):
- AudioKit/Core
- PandoraPlayer (1.3):
- AudioKit (~> 4.5)

DEPENDENCIES:
- PandoraPlayer (from `..`)

SPEC REPOS:
trunk:
- AudioKit

EXTERNAL SOURCES:
PandoraPlayer:
:path: ".."

SPEC CHECKSUMS:
AudioKit: b8e508a0af3dc7d53caf0ca1002b187a662f949e
PandoraPlayer: 83e5993169f43f67c9d35960055675df81575703

PODFILE CHECKSUM: bbcfa087c0e05b35ea9f1d2184ff4ecfcaf641d1

COCOAPODS: 1.9.3
5 changes: 3 additions & 2 deletions PandoraPlayer.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "PandoraPlayer"
s.version = "1.2"
s.version = "1.3"
s.summary = "Music Player for iOS"
s.description = "A simple iOS music player library written in Swift"

Expand All @@ -10,6 +10,7 @@ Pod::Spec.new do |s|

s.author = { "Applikey Solutions" => "[email protected]" }
s.platform = :ios, "9.0"
s.static_framework = true

s.source = { :git => "https://github.com/AppliKeySolutions/PandoraPlayer.git", :tag => "#{s.version}" }

Expand All @@ -18,6 +19,6 @@ Pod::Spec.new do |s|

s.resources = "Player/**/*.{storyboard,xib,xcassets}"

s.dependency "AudioKit", "4.0.3"
s.dependency "AudioKit", "~> 4.5"

end
13 changes: 3 additions & 10 deletions Player.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@
children = (
F519AE031F2B26870067FE47 /* Classes */,
F519AE291F2B26870067FE47 /* Resources */,
F519AE2D1F2B26870067FE47 /* Supporting Files */,
);
path = Player;
sourceTree = "<group>";
Expand Down Expand Up @@ -255,13 +254,6 @@
path = Resources;
sourceTree = "<group>";
};
F519AE2D1F2B26870067FE47 /* Supporting Files */ = {
isa = PBXGroup;
children = (
);
path = "Supporting Files";
sourceTree = "<group>";
};
F519B7921F2B371D0067FE47 /* Storyboards */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -324,6 +316,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
Base,
);
Expand Down Expand Up @@ -540,7 +533,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.applikeySolutions.Player;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = 1;
};
name = Debug;
Expand All @@ -561,7 +554,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.applikeySolutions.Player;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = 1;
};
name = Release;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http:https://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http:https://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>Player.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
17 changes: 12 additions & 5 deletions Player/Classes/Controllers/PandoraPlayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ open class PandoraPlayer: UIViewController {
*/
public static func configure(withPaths paths: [String]) -> PandoraPlayer {
let playerVC = pandoraPlayerInstance()
let songItems = paths.flatMap({ return Song(path: $0) })
let songItems = paths.compactMap({ return Song(path: $0) })
playerVC.library = songItems
playerVC.readyForPlay()
return playerVC
Expand All @@ -153,7 +153,7 @@ open class PandoraPlayer: UIViewController {
*/
public static func configure(withAVItems items: [AVPlayerItem]) -> PandoraPlayer {
let playerVC = pandoraPlayerInstance()
let songItems = items.flatMap({ return Song(withAVPlayerItem: $0) })
let songItems = items.compactMap({ return Song(withAVPlayerItem: $0) })
playerVC.library = songItems
playerVC.readyForPlay()
return playerVC
Expand Down Expand Up @@ -201,7 +201,6 @@ open class PandoraPlayer: UIViewController {
playerVC.library = outputItems

group.notify(queue: DispatchQueue.main) {
assert(outputItems.count > 0)
playerVC.library = outputItems
playerVC.readyForPlay()
}
Expand Down Expand Up @@ -232,6 +231,7 @@ open class PandoraPlayer: UIViewController {
configureNavigationBar()
configurePlayer()
configurePlayerSongListView()
configureBackgroundImage()
}

private func configurePlayerSongListView() {
Expand All @@ -243,7 +243,7 @@ open class PandoraPlayer: UIViewController {
navigationController?.navigationBar.shadowImage = UIImage()
navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)

navigationController?.navigationBar.titleTextAttributes = [NSAttributedStringKey.foregroundColor: UIColor.white]
navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white]
navigationController?.navigationBar.tintColor = UIColor.white
title = nowPlaying
}
Expand Down Expand Up @@ -335,6 +335,9 @@ open class PandoraPlayer: UIViewController {
}

private func configurePlayer() {
if !self.isViewLoaded {
_ = self.view // Make sure to load views first
}
configurePlayerControls()
configurePlayerTimeSlider()
player = EZAudioPlayer()
Expand Down Expand Up @@ -506,7 +509,7 @@ extension PandoraPlayer: PlayerSongListDelegate {
guard library[index].colors == nil else { continue }
guard tasks[index] == nil else { continue }
var item: DispatchWorkItem!
item = DispatchWorkItem(block: {
item = DispatchWorkItem(block: {[unowned self] in
guard !item.isCancelled else { return }
guard let image = self.library[index].metadata?.artwork else { return }
guard !item.isCancelled else { return }
Expand Down Expand Up @@ -555,6 +558,10 @@ extension PandoraPlayer: PlayerControlsDelegate {

extension PandoraPlayer: PlayerSliderProtocol {
func onValueChanged(progress: Float, timePast: TimeInterval) {
guard player.audioFile != nil else {
sliderView.progress = 0
return
}
beeingSeek = true
let frame = Int64(Float(player.audioFile.totalFrames) * progress)
self.player.seek(toFrame: frame)
Expand Down
8 changes: 4 additions & 4 deletions Player/Classes/Extensions/CommonExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ extension UILabel {
if layer.animation(forKey: animation) == nil {
let transition = CATransition()
transition.duration = duration
transition.type = kCATransitionFade
transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
transition.type = CATransitionType.fade
transition.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeInEaseOut)
layer.add(transition, forKey: animation)
}
self.text = text
Expand All @@ -60,8 +60,8 @@ extension CATransition {
static func fading(_ duration: TimeInterval) -> CATransition {
let transition = CATransition()
transition.duration = duration
transition.type = kCATransitionFade
transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
transition.type = CATransitionType.fade
transition.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeInEaseOut)
return transition
}
}
6 changes: 3 additions & 3 deletions Player/Classes/Vendors/UIImageColors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ extension UIColor {
let fg = compareColor.cgColor.components
let threshold: CGFloat = 0.25

if fabs(bg[0] - fg[0]) > threshold || fabs(bg[1] - fg[1]) > threshold || fabs(bg[2] - fg[2]) > threshold {
if fabs(bg[0] - bg[1]) < 0.03 && fabs(bg[0] - bg[2]) < 0.03 {
if fabs(fg[0] - fg[1]) < 0.03 && fabs(fg[0] - fg[2]) < 0.03 {
if abs(bg[0] - fg[0]) > threshold || abs(bg[1] - fg[1]) > threshold || abs(bg[2] - fg[2]) > threshold {
if abs(bg[0] - bg[1]) < 0.03 && abs(bg[0] - bg[2]) < 0.03 {
if abs(fg[0] - fg[1]) < 0.03 && abs(fg[0] - fg[2]) < 0.03 {
return false
}
}
Expand Down
Loading