Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions AGAudioPlayer.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ Pod::Spec.new do |s|
s.ios.frameworks = 'MediaPlayer'
s.resource_bundle = { 'AGAudioPlayer' => ['AGAudioPlayer/UI/Icons.xcassets', 'AGAudioPlayer/**/*.xib'] }

s.static_framework = true
s.dependency 'Interpolate'
s.dependency 'BASSGaplessAudioPlayer'
s.dependency 'google-cast-sdk'
s.dependency 'MarqueeLabel'
s.dependency 'NapySlider'
end
15 changes: 14 additions & 1 deletion AGAudioPlayer/UI/AGAudioPlayerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import UIKit
import QuartzCore
import MediaPlayer

import GoogleCast
import Interpolate
import MarqueeLabel
import NapySlider
Expand Down Expand Up @@ -145,11 +146,16 @@ public struct AGAudioPlayerColors {
// for delegate notifications
var lastSeenProgress: Float? = nil

var uiCastButton: GCKUICastButton

let player: AGAudioPlayer

@objc required public init(player: AGAudioPlayer) {
self.player = player

// Calling this more than once freezes the app. Instead, create a singleton and move it around the UI as needed
self.uiCastButton = GCKUICastButton(frame: CGRect(x: 0, y: 0, width: 24, height: 24))

let bundle = Bundle(path: Bundle(for: AGAudioPlayerViewController.self).path(forResource: "AGAudioPlayer", ofType: "bundle")!)
super.init(nibName: String(describing: AGAudioPlayerViewController.self), bundle: bundle)

Expand All @@ -173,6 +179,9 @@ public struct AGAudioPlayerColors {
uiMiniButtonPlus.isHidden = true
uiButtonPlus.alpha = 0.0

uiCastButton.tintColor = UIColor.white
uiMiniButtonStack.insertArrangedSubview(uiCastButton, at: uiMiniPlayerContainerView.subviews.count - 1)

setupTable()
setupStretchyHeader()
setupColors()
Expand Down Expand Up @@ -574,14 +583,18 @@ public protocol AGAudioPlayerViewControllerDelegate {

extension AGAudioPlayerViewController {
public func switchToMiniPlayer(animated: Bool) {
uiButtonStack.removeArrangedSubview(uiCastButton)
uiMiniButtonStack.insertArrangedSubview(uiCastButton, at: uiMiniButtonStack.arrangedSubviews.count - 1)
view.layoutIfNeeded()

UIView.animate(withDuration: 0.3) {
UIView.animate(withDuration: 0.3) {
self.switchToMiniPlayerProgress(1.0)
}
}

public func switchToFullPlayer(animated: Bool) {
uiMiniButtonStack.removeArrangedSubview(uiCastButton)
uiButtonStack.insertArrangedSubview(uiCastButton, at: uiButtonStack.arrangedSubviews.count - 2)
view.layoutIfNeeded()

UIView.animate(withDuration: 0.3) {
Expand Down