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
6 changes: 3 additions & 3 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PODS:
- SwiftAudioPlayer (7.5.0)
- SwiftAudioPlayer (7.6.0)

DEPENDENCIES:
- SwiftAudioPlayer (from `../`)
Expand All @@ -9,8 +9,8 @@ EXTERNAL SOURCES:
:path: "../"

SPEC CHECKSUMS:
SwiftAudioPlayer: f94f6350ba7d658b0bd290ce3b57cbf14139f072
SwiftAudioPlayer: a546709faf47f3ab0cb59e41ba4432e6bb61db0a

PODFILE CHECKSUM: 92c7367b33454536515e31bf5d93e792787f3f4a

COCOAPODS: 1.10.1
COCOAPODS: 1.11.2
23 changes: 9 additions & 14 deletions Example/SwiftAudioPlayer/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,46 +6,41 @@
// Copyright (c) 2019 tanhakabir. All rights reserved.
//

import UIKit
import SwiftAudioPlayer
import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
func application(_: UIApplication, didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}

func applicationWillResignActive(_ application: UIApplication) {
func applicationWillResignActive(_: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

func applicationDidEnterBackground(_ application: UIApplication) {
func applicationDidEnterBackground(_: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

func applicationWillEnterForeground(_ application: UIApplication) {
func applicationWillEnterForeground(_: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

func applicationDidBecomeActive(_ application: UIApplication) {
func applicationDidBecomeActive(_: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

func applicationWillTerminate(_ application: UIApplication) {
func applicationWillTerminate(_: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
func application(_ application: UIApplication, handleEventsForBackgroundURLSession identifier: String, completionHandler: @escaping () -> Void) {

func application(_: UIApplication, handleEventsForBackgroundURLSession _: String, completionHandler: @escaping () -> Void) {
SAPlayer.Downloader.setBackgroundCompletionHandler(completionHandler)
}


}

38 changes: 17 additions & 21 deletions Example/SwiftAudioPlayer/Model.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import SwiftAudioPlayer

struct AudioInfo: Hashable {
var index: Int = 0

var urls: [URL] = [URL(string: "https://www.fesliyanstudios.com/musicfiles/2019-04-23_-_Trusted_Advertising_-_www.fesliyanstudios.com/15SecVersion2019-04-23_-_Trusted_Advertising_-_www.fesliyanstudios.com.mp3")!,
URL(string: "https://chtbl.com/track/18338/traffic.libsyn.com/secure/acquired/acquired_-_armrev_2.mp3?dest-id=376122")!,
URL(string: "https://ice6.somafm.com/groovesalad-256-mp3")!]

var url: URL {
switch index {
case 0:
Expand All @@ -28,7 +28,7 @@ struct AudioInfo: Hashable {
return urls[0]
}
}

var title: String {
switch index {
case 0:
Expand All @@ -41,48 +41,44 @@ struct AudioInfo: Hashable {
return "Soundbite"
}
}

let artist: String = "SwiftAudioPlayer Sample App"
let releaseDate: Int = 1550790640
let releaseDate: Int = 1_550_790_640

var lockscreenInfo: SALockScreenInfo {
get {
return SALockScreenInfo(title: self.title, artist: self.artist, albumTitle: nil, artwork: nil, releaseDate: self.releaseDate)
}
return SALockScreenInfo(title: title, artist: artist, albumTitle: nil, artwork: nil, releaseDate: releaseDate)
}

var savedUrl: URL? {
get {
return savedUrls[index]
}
return savedUrls[index]
}

var savedUrls: [URL?] = [nil, nil, nil]

mutating func addSavedUrl(_ url: URL) {
savedUrls[index] = url
}

mutating func deleteSavedUrl() {
savedUrls[index] = nil
}

mutating func addSavedUrl(_ url: URL, atIndex i: Int) {
savedUrls[i] = url
}

mutating func deleteSavedUrl(atIndex i: Int) {
savedUrls[i] = nil
}

func getUrl(atIndex i: Int) -> URL {
return urls[i]
}

mutating func setIndex(_ i: Int) {
index = i
}

func getIndex(forURL url: URL) -> Int? {
return urls.firstIndex(of: url) ?? savedUrls.firstIndex(of: url)
}
Expand Down
Loading