-
-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1164 from TortugaPower/develop
Release v5.3.3
- Loading branch information
Showing
73 changed files
with
1,156 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// | ||
// CustomRewindIntent.swift | ||
// BookPlayer | ||
// | ||
// Created by Gianni Carlo on 31/7/24. | ||
// Copyright © 2024 Tortuga Power. All rights reserved. | ||
// | ||
|
||
import BookPlayerKit | ||
import Foundation | ||
import AppIntents | ||
|
||
@available(iOS 16.4, macOS 14.0, watchOS 10.0, tvOS 16.0, *) | ||
struct CustomRewindIntent: AudioStartingIntent, ForegroundContinuableIntent { | ||
static var title: LocalizedStringResource = "intent_custom_skiprewind_title" | ||
|
||
@Parameter( | ||
title: LocalizedStringResource("intent_custom_interval_title"), | ||
requestValueDialog: IntentDialog(LocalizedStringResource("intent_custom_skip_request_title")) | ||
) | ||
var interval: Measurement<UnitDuration> | ||
|
||
static var parameterSummary: some ParameterSummary { | ||
Summary("Rewind \(\.$interval)") | ||
} | ||
|
||
func perform() async throws -> some IntentResult { | ||
let seconds = interval.converted(to: .seconds).value | ||
let stack = try await DatabaseInitializer().loadCoreDataStack() | ||
|
||
let continuation: (@MainActor () async throws -> Void) = { | ||
let actionString = CommandParser.createActionString( | ||
from: .skipRewind, | ||
parameters: [URLQueryItem(name: "interval", value: "\(seconds)")] | ||
) | ||
let actionURL = URL(string: actionString)! | ||
UIApplication.shared.open(actionURL) | ||
} | ||
|
||
guard let appDelegate = await AppDelegate.shared else { | ||
throw needsToContinueInForegroundError(continuation: continuation) | ||
} | ||
|
||
let coreServices = await appDelegate.createCoreServicesIfNeeded(from: stack) | ||
|
||
guard coreServices.playerManager.hasLoadedBook() else { | ||
throw needsToContinueInForegroundError(continuation: continuation) | ||
} | ||
|
||
coreServices.playerManager.skip(-seconds) | ||
|
||
return .result() | ||
} | ||
} |
Oops, something went wrong.