Repository Public
1// =============================================================================2// SP BOUCHER | SOFTWARE & RESEARCH3// ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// PROJECT METADATA7// -----------------------------------------------------------------------------8// Project : SP Music9// File : App/SPMusicApp.swift10// Description : App entry point, app delegate (background download events,11// scene routing) and keyboard commands.12// Module : App13// Repository : https://git.spboucher.ai/sp-music-ios14// Created : 2026-11-1715// Last Modified : 2026-11-1716//17// =============================================================================18// AUTHOR & PROFESSIONAL AFFILIATION19// =============================================================================20//21// Author : Simon-Pierre Boucher22// Position : Professor of Finance23// Institution : Université du Québec en Outaouais (UQO)24// Department : Département des sciences administratives25// Organization : SP Boucher26//27// Website : https://spboucher.ai28// Git : https://git.spboucher.ai29//30// =============================================================================31// OFFICIAL CONTACT DIRECTORY32// =============================================================================33//34// General : info@spboucher.ai35// Professional : contact@spboucher.ai36// Direct : simon@spboucher.ai37// Research : research@spboucher.ai38// Development : dev@spboucher.ai39// Support : support@spboucher.ai40// Security/Admin : admin@spboucher.ai41// Notifications : notifications@spboucher.ai42//43// Preferred Contact: support@spboucher.ai44//45// =============================================================================46// COPYRIGHT & INTELLECTUAL PROPERTY47// =============================================================================48//49// Copyright (c) 202650// Simon-Pierre Boucher51//52// All rights reserved where applicable.53//54// This file is governed by the applicable project license,55// copyright notices, institutional agreements and relevant law.56//57// Unless expressly authorized by the applicable license or58// rights holder, copying, redistribution, sublicensing,59// publication and commercial exploitation are not permitted.60//61// Existing third-party rights and notices remain unaffected.62//63// =============================================================================64// CONFIDENTIALITY & SECURITY65// =============================================================================66//67// Classification : Public68// Distribution : Public repository; use is governed by the project license69// Security Contact : admin@spboucher.ai70//71// Access to this source does not independently grant permission72// to redistribute or disclose confidential materials.73//74// Do not embed credentials, private keys, access tokens,75// certificates or confidential personal information.76//77// =============================================================================78// LICENSE & MAINTENANCE79// =============================================================================80//81// License : None specified (no license file in this repository)82// Maintainer : Simon-Pierre Boucher83// Technical Contact: dev@spboucher.ai84//85// =============================================================================86// END OF SP BOUCHER SOURCE HEADER87// =============================================================================8889import SPMusicCore90import SwiftUI91import UIKit9293final class AppDelegate: NSObject, UIApplicationDelegate {94 /// iOS relaunches or wakes the app when background downloads finished while it was not running.95 func application(_ application: UIApplication, handleEventsForBackgroundURLSession identifier: String, completionHandler: @escaping @Sendable () -> Void) {96 guard identifier == DownloadManager.backgroundIdentifier else { completionHandler(); return }97 let env = AppEnvironment.shared98 Task { @MainActor in99 await env.downloads.setBackgroundCompletion { DispatchQueue.main.async { completionHandler() } }100 await env.start()101 }102 }103104 func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {105 if connectingSceneSession.role == .carTemplateApplication {106 let c = UISceneConfiguration(name: "CarPlay", sessionRole: connectingSceneSession.role)107 c.delegateClass = CarPlaySceneDelegate.self108 return c109 }110 return UISceneConfiguration(name: nil, sessionRole: connectingSceneSession.role)111 }112}113114@main115struct SPMusicApp: App {116 @UIApplicationDelegateAdaptor(AppDelegate.self) private var delegate117 @State private var env = AppEnvironment.shared118119 var body: some Scene {120 WindowGroup {121 RootView().environment(env)122 }123 .commands {124 // Hardware keyboard (iPad): the usual playback shortcuts, also listed when ⌘ is held.125 CommandMenu("Lecture") {126 Button(env.player.isPlaying ? "Pause" : "Lecture") { env.player.toggle() }.keyboardShortcut(.space, modifiers: [])127 Button("Titre suivant") { env.player.next() }.keyboardShortcut(.rightArrow, modifiers: .command)128 Button("Titre précédent") { env.player.previous() }.keyboardShortcut(.leftArrow, modifiers: .command)129 Divider()130 Button("Lecture aléatoire") { env.player.setShuffle(!env.player.queue.shuffle) }.keyboardShortcut("s", modifiers: [.command, .shift])131 Button("Répétition") { env.player.cycleRepeat() }.keyboardShortcut("r", modifiers: [.command, .shift])132 Divider()133 Button("Afficher le lecteur") { env.showNowPlaying.toggle() }.keyboardShortcut("l", modifiers: .command)134 Button("Synchroniser") { Task { await env.syncNow() } }.keyboardShortcut("r", modifiers: .command)135 }136 }137 }138}139