react-native-queue-player 1.0.9 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -6
- package/android/src/main/java/com/margelo/nitro/queueplayer/QueueSkipArithmetic.kt +57 -10
- package/android/src/main/java/com/margelo/nitro/queueplayer/TrackPlayer.kt +45 -16
- package/android/src/test/java/com/margelo/nitro/queueplayer/PlaybackServiceCallbackTest.kt +1 -1
- package/android/src/test/java/com/margelo/nitro/queueplayer/QueueSkipArithmeticTest.kt +103 -0
- package/android/src/test/java/com/margelo/nitro/queueplayer/TrackPlayerAirPlayMetadataWiringTest.kt +1 -1
- package/android/src/test/java/com/margelo/nitro/queueplayer/TrackPlayerAudioFocusTest.kt +1 -1
- package/android/src/test/java/com/margelo/nitro/queueplayer/TrackPlayerEventsTest.kt +3 -3
- package/android/src/test/java/com/margelo/nitro/queueplayer/TrackPlayerLifecycleTest.kt +7 -7
- package/android/src/test/java/com/margelo/nitro/queueplayer/TrackPlayerLookaheadConfigTest.kt +6 -6
- package/android/src/test/java/com/margelo/nitro/queueplayer/TrackPlayerMutationTest.kt +2 -2
- package/android/src/test/java/com/margelo/nitro/queueplayer/TrackPlayerProgressThrottleTest.kt +1 -1
- package/android/src/test/java/com/margelo/nitro/queueplayer/TrackPlayerQueueChangeTest.kt +1 -1
- package/android/src/test/java/com/margelo/nitro/queueplayer/TrackPlayerQueueTest.kt +1 -1
- package/android/src/test/java/com/margelo/nitro/queueplayer/TrackPlayerReadersTest.kt +1 -1
- package/android/src/test/java/com/margelo/nitro/queueplayer/TrackPlayerSkipCapabilityTest.kt +41 -2
- package/android/src/test/java/com/margelo/nitro/queueplayer/TrackPlayerSkipTest.kt +34 -1
- package/android/src/test/java/com/margelo/nitro/queueplayer/TrackPlayerTransportTest.kt +1 -1
- package/ios/QueueSkipArithmetic.swift +55 -9
- package/ios/Tests/AVQueueBuilderTests.swift +9 -9
- package/ios/Tests/SkipIndexTests.swift +97 -0
- package/ios/TrackPlayer.swift +37 -13
- package/lib/module/index.js.map +1 -1
- package/lib/module/types.js +9 -0
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/TrackPlayer.nitro.d.ts +7 -7
- package/lib/typescript/index.d.ts +1 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/types.d.ts +24 -0
- package/lib/typescript/types.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JHybridTrackPlayerSpec.cpp +4 -0
- package/nitrogen/generated/android/c++/JPlayerConfig.hpp +7 -1
- package/nitrogen/generated/android/c++/JSkipToPreviousBehavior.hpp +58 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/queueplayer/PlayerConfig.kt +7 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/queueplayer/SkipToPreviousBehavior.kt +23 -0
- package/nitrogen/generated/ios/QueuePlayer-Swift-Cxx-Bridge.hpp +18 -0
- package/nitrogen/generated/ios/QueuePlayer-Swift-Cxx-Umbrella.hpp +3 -0
- package/nitrogen/generated/ios/c++/HybridTrackPlayerSpecSwift.hpp +3 -0
- package/nitrogen/generated/ios/swift/PlayerConfig.swift +12 -1
- package/nitrogen/generated/ios/swift/SkipToPreviousBehavior.swift +40 -0
- package/nitrogen/generated/shared/c++/PlayerConfig.hpp +8 -1
- package/nitrogen/generated/shared/c++/SkipToPreviousBehavior.hpp +76 -0
- package/package.json +1 -1
- package/src/TrackPlayer.nitro.ts +7 -7
- package/src/index.ts +1 -0
- package/src/types.ts +25 -0
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
#include "JAudioCategoryOptions.hpp"
|
|
17
17
|
#include "JAudioContentType.hpp"
|
|
18
18
|
#include "JEvictionPolicy.hpp"
|
|
19
|
+
#include "JSkipToPreviousBehavior.hpp"
|
|
20
|
+
#include "SkipToPreviousBehavior.hpp"
|
|
19
21
|
#include <optional>
|
|
20
22
|
#include <string>
|
|
21
23
|
#include <unordered_map>
|
|
@@ -59,6 +61,8 @@ namespace margelo::nitro::queueplayer {
|
|
|
59
61
|
jni::local_ref<jni::JBoolean> visualizationEnabled = this->getFieldValue(fieldVisualizationEnabled);
|
|
60
62
|
static const auto fieldClampSeekToBuffered = clazz->getField<jni::JBoolean>("clampSeekToBuffered");
|
|
61
63
|
jni::local_ref<jni::JBoolean> clampSeekToBuffered = this->getFieldValue(fieldClampSeekToBuffered);
|
|
64
|
+
static const auto fieldSkipToPreviousBehavior = clazz->getField<JSkipToPreviousBehavior>("skipToPreviousBehavior");
|
|
65
|
+
jni::local_ref<JSkipToPreviousBehavior> skipToPreviousBehavior = this->getFieldValue(fieldSkipToPreviousBehavior);
|
|
62
66
|
static const auto fieldLookaheadCacheMaxSizeMb = clazz->getField<jni::JDouble>("lookaheadCacheMaxSizeMb");
|
|
63
67
|
jni::local_ref<jni::JDouble> lookaheadCacheMaxSizeMb = this->getFieldValue(fieldLookaheadCacheMaxSizeMb);
|
|
64
68
|
static const auto fieldLookaheadCacheEvictionPolicy = clazz->getField<JEvictionPolicy>("lookaheadCacheEvictionPolicy");
|
|
@@ -85,6 +89,7 @@ namespace margelo::nitro::queueplayer {
|
|
|
85
89
|
audioCategoryOptions != nullptr ? std::make_optional(audioCategoryOptions->toCpp()) : std::nullopt,
|
|
86
90
|
visualizationEnabled != nullptr ? std::make_optional(static_cast<bool>(visualizationEnabled->value())) : std::nullopt,
|
|
87
91
|
clampSeekToBuffered != nullptr ? std::make_optional(static_cast<bool>(clampSeekToBuffered->value())) : std::nullopt,
|
|
92
|
+
skipToPreviousBehavior != nullptr ? std::make_optional(skipToPreviousBehavior->toCpp()) : std::nullopt,
|
|
88
93
|
lookaheadCacheMaxSizeMb != nullptr ? std::make_optional(lookaheadCacheMaxSizeMb->value()) : std::nullopt,
|
|
89
94
|
lookaheadCacheEvictionPolicy != nullptr ? std::make_optional(lookaheadCacheEvictionPolicy->toCpp()) : std::nullopt,
|
|
90
95
|
progressUpdateIntervalMs != nullptr ? std::make_optional(progressUpdateIntervalMs->value()) : std::nullopt,
|
|
@@ -98,7 +103,7 @@ namespace margelo::nitro::queueplayer {
|
|
|
98
103
|
*/
|
|
99
104
|
[[maybe_unused]]
|
|
100
105
|
static jni::local_ref<JPlayerConfig::javaobject> fromCpp(const PlayerConfig& value) {
|
|
101
|
-
using JSignature = JPlayerConfig(jni::alias_ref<jni::JMap<jni::JString, jni::JString>>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JDouble>, jni::alias_ref<JAudioContentType>, jni::alias_ref<JAudioCategoryOptions>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<jni::JDouble>, jni::alias_ref<JEvictionPolicy>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JDouble>);
|
|
106
|
+
using JSignature = JPlayerConfig(jni::alias_ref<jni::JMap<jni::JString, jni::JString>>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JDouble>, jni::alias_ref<JAudioContentType>, jni::alias_ref<JAudioCategoryOptions>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<JSkipToPreviousBehavior>, jni::alias_ref<jni::JDouble>, jni::alias_ref<JEvictionPolicy>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JDouble>);
|
|
102
107
|
static const auto clazz = javaClassStatic();
|
|
103
108
|
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
104
109
|
return create(
|
|
@@ -119,6 +124,7 @@ namespace margelo::nitro::queueplayer {
|
|
|
119
124
|
value.audioCategoryOptions.has_value() ? JAudioCategoryOptions::fromCpp(value.audioCategoryOptions.value()) : nullptr,
|
|
120
125
|
value.visualizationEnabled.has_value() ? jni::JBoolean::valueOf(value.visualizationEnabled.value()) : nullptr,
|
|
121
126
|
value.clampSeekToBuffered.has_value() ? jni::JBoolean::valueOf(value.clampSeekToBuffered.value()) : nullptr,
|
|
127
|
+
value.skipToPreviousBehavior.has_value() ? JSkipToPreviousBehavior::fromCpp(value.skipToPreviousBehavior.value()) : nullptr,
|
|
122
128
|
value.lookaheadCacheMaxSizeMb.has_value() ? jni::JDouble::valueOf(value.lookaheadCacheMaxSizeMb.value()) : nullptr,
|
|
123
129
|
value.lookaheadCacheEvictionPolicy.has_value() ? JEvictionPolicy::fromCpp(value.lookaheadCacheEvictionPolicy.value()) : nullptr,
|
|
124
130
|
value.progressUpdateIntervalMs.has_value() ? jni::JDouble::valueOf(value.progressUpdateIntervalMs.value()) : nullptr,
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JSkipToPreviousBehavior.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include "SkipToPreviousBehavior.hpp"
|
|
12
|
+
|
|
13
|
+
namespace margelo::nitro::queueplayer {
|
|
14
|
+
|
|
15
|
+
using namespace facebook;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The C++ JNI bridge between the C++ enum "SkipToPreviousBehavior" and the Kotlin enum "SkipToPreviousBehavior".
|
|
19
|
+
*/
|
|
20
|
+
struct JSkipToPreviousBehavior final: public jni::JavaClass<JSkipToPreviousBehavior> {
|
|
21
|
+
public:
|
|
22
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/queueplayer/SkipToPreviousBehavior;";
|
|
23
|
+
|
|
24
|
+
public:
|
|
25
|
+
/**
|
|
26
|
+
* Convert this Java/Kotlin-based enum to the C++ enum SkipToPreviousBehavior.
|
|
27
|
+
*/
|
|
28
|
+
[[maybe_unused]]
|
|
29
|
+
[[nodiscard]]
|
|
30
|
+
SkipToPreviousBehavior toCpp() const {
|
|
31
|
+
static const auto clazz = javaClassStatic();
|
|
32
|
+
static const auto fieldOrdinal = clazz->getField<int>("value");
|
|
33
|
+
int ordinal = this->getFieldValue(fieldOrdinal);
|
|
34
|
+
return static_cast<SkipToPreviousBehavior>(ordinal);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public:
|
|
38
|
+
/**
|
|
39
|
+
* Create a Java/Kotlin-based enum with the given C++ enum's value.
|
|
40
|
+
*/
|
|
41
|
+
[[maybe_unused]]
|
|
42
|
+
static jni::alias_ref<JSkipToPreviousBehavior> fromCpp(SkipToPreviousBehavior value) {
|
|
43
|
+
static const auto clazz = javaClassStatic();
|
|
44
|
+
switch (value) {
|
|
45
|
+
case SkipToPreviousBehavior::PREVIOUS:
|
|
46
|
+
static const auto fieldPREVIOUS = clazz->getStaticField<JSkipToPreviousBehavior>("PREVIOUS");
|
|
47
|
+
return clazz->getStaticFieldValue(fieldPREVIOUS);
|
|
48
|
+
case SkipToPreviousBehavior::RESTART_OR_PREVIOUS:
|
|
49
|
+
static const auto fieldRESTART_OR_PREVIOUS = clazz->getStaticField<JSkipToPreviousBehavior>("RESTART_OR_PREVIOUS");
|
|
50
|
+
return clazz->getStaticFieldValue(fieldRESTART_OR_PREVIOUS);
|
|
51
|
+
default:
|
|
52
|
+
std::string stringValue = std::to_string(static_cast<int>(value));
|
|
53
|
+
throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
} // namespace margelo::nitro::queueplayer
|
|
@@ -50,6 +50,9 @@ data class PlayerConfig(
|
|
|
50
50
|
val clampSeekToBuffered: Boolean?,
|
|
51
51
|
@DoNotStrip
|
|
52
52
|
@Keep
|
|
53
|
+
val skipToPreviousBehavior: SkipToPreviousBehavior?,
|
|
54
|
+
@DoNotStrip
|
|
55
|
+
@Keep
|
|
53
56
|
val lookaheadCacheMaxSizeMb: Double?,
|
|
54
57
|
@DoNotStrip
|
|
55
58
|
@Keep
|
|
@@ -76,6 +79,7 @@ data class PlayerConfig(
|
|
|
76
79
|
&& Objects.deepEquals(this.audioCategoryOptions, other.audioCategoryOptions)
|
|
77
80
|
&& Objects.deepEquals(this.visualizationEnabled, other.visualizationEnabled)
|
|
78
81
|
&& Objects.deepEquals(this.clampSeekToBuffered, other.clampSeekToBuffered)
|
|
82
|
+
&& Objects.deepEquals(this.skipToPreviousBehavior, other.skipToPreviousBehavior)
|
|
79
83
|
&& Objects.deepEquals(this.lookaheadCacheMaxSizeMb, other.lookaheadCacheMaxSizeMb)
|
|
80
84
|
&& Objects.deepEquals(this.lookaheadCacheEvictionPolicy, other.lookaheadCacheEvictionPolicy)
|
|
81
85
|
&& Objects.deepEquals(this.progressUpdateIntervalMs, other.progressUpdateIntervalMs)
|
|
@@ -94,6 +98,7 @@ data class PlayerConfig(
|
|
|
94
98
|
audioCategoryOptions,
|
|
95
99
|
visualizationEnabled,
|
|
96
100
|
clampSeekToBuffered,
|
|
101
|
+
skipToPreviousBehavior,
|
|
97
102
|
lookaheadCacheMaxSizeMb,
|
|
98
103
|
lookaheadCacheEvictionPolicy,
|
|
99
104
|
progressUpdateIntervalMs,
|
|
@@ -109,8 +114,8 @@ data class PlayerConfig(
|
|
|
109
114
|
@Keep
|
|
110
115
|
@Suppress("unused")
|
|
111
116
|
@JvmStatic
|
|
112
|
-
private fun fromCpp(httpHeaders: Map<String, String>?, userAgent: String?, placeholderArtworkUri: String?, autoRetries: Double?, retryBackoffMs: Double?, networkTimeoutMs: Double?, audioContentType: AudioContentType?, audioCategoryOptions: AudioCategoryOptions?, visualizationEnabled: Boolean?, clampSeekToBuffered: Boolean?, lookaheadCacheMaxSizeMb: Double?, lookaheadCacheEvictionPolicy: EvictionPolicy?, progressUpdateIntervalMs: Double?, backgroundProgressUpdateIntervalMs: Double?): PlayerConfig {
|
|
113
|
-
return PlayerConfig(httpHeaders, userAgent, placeholderArtworkUri, autoRetries, retryBackoffMs, networkTimeoutMs, audioContentType, audioCategoryOptions, visualizationEnabled, clampSeekToBuffered, lookaheadCacheMaxSizeMb, lookaheadCacheEvictionPolicy, progressUpdateIntervalMs, backgroundProgressUpdateIntervalMs)
|
|
117
|
+
private fun fromCpp(httpHeaders: Map<String, String>?, userAgent: String?, placeholderArtworkUri: String?, autoRetries: Double?, retryBackoffMs: Double?, networkTimeoutMs: Double?, audioContentType: AudioContentType?, audioCategoryOptions: AudioCategoryOptions?, visualizationEnabled: Boolean?, clampSeekToBuffered: Boolean?, skipToPreviousBehavior: SkipToPreviousBehavior?, lookaheadCacheMaxSizeMb: Double?, lookaheadCacheEvictionPolicy: EvictionPolicy?, progressUpdateIntervalMs: Double?, backgroundProgressUpdateIntervalMs: Double?): PlayerConfig {
|
|
118
|
+
return PlayerConfig(httpHeaders, userAgent, placeholderArtworkUri, autoRetries, retryBackoffMs, networkTimeoutMs, audioContentType, audioCategoryOptions, visualizationEnabled, clampSeekToBuffered, skipToPreviousBehavior, lookaheadCacheMaxSizeMb, lookaheadCacheEvictionPolicy, progressUpdateIntervalMs, backgroundProgressUpdateIntervalMs)
|
|
114
119
|
}
|
|
115
120
|
}
|
|
116
121
|
}
|
package/nitrogen/generated/android/kotlin/com/margelo/nitro/queueplayer/SkipToPreviousBehavior.kt
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// SkipToPreviousBehavior.kt
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
package com.margelo.nitro.queueplayer
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Represents the JavaScript enum/union "SkipToPreviousBehavior".
|
|
15
|
+
*/
|
|
16
|
+
@DoNotStrip
|
|
17
|
+
@Keep
|
|
18
|
+
enum class SkipToPreviousBehavior(@DoNotStrip @Keep val value: Int) {
|
|
19
|
+
PREVIOUS(0),
|
|
20
|
+
RESTART_OR_PREVIOUS(1);
|
|
21
|
+
|
|
22
|
+
companion object
|
|
23
|
+
}
|
|
@@ -112,6 +112,8 @@ namespace margelo::nitro::queueplayer { enum class ServiceReadyReason; }
|
|
|
112
112
|
namespace margelo::nitro::queueplayer { struct ShuffleResult; }
|
|
113
113
|
// Forward declaration of `SkipCapability` to properly resolve imports.
|
|
114
114
|
namespace margelo::nitro::queueplayer { struct SkipCapability; }
|
|
115
|
+
// Forward declaration of `SkipToPreviousBehavior` to properly resolve imports.
|
|
116
|
+
namespace margelo::nitro::queueplayer { enum class SkipToPreviousBehavior; }
|
|
115
117
|
// Forward declaration of `SleepTimerState` to properly resolve imports.
|
|
116
118
|
namespace margelo::nitro::queueplayer { struct SleepTimerState; }
|
|
117
119
|
// Forward declaration of `StateChangeReason` to properly resolve imports.
|
|
@@ -189,6 +191,7 @@ namespace QueuePlayer { class HybridVisualizerSpec_cxx; }
|
|
|
189
191
|
#include "ServiceReadyReason.hpp"
|
|
190
192
|
#include "ShuffleResult.hpp"
|
|
191
193
|
#include "SkipCapability.hpp"
|
|
194
|
+
#include "SkipToPreviousBehavior.hpp"
|
|
192
195
|
#include "SleepTimerState.hpp"
|
|
193
196
|
#include "StateChangeReason.hpp"
|
|
194
197
|
#include "TrackChangeReason.hpp"
|
|
@@ -785,6 +788,21 @@ namespace margelo::nitro::queueplayer::bridge::swift {
|
|
|
785
788
|
return optional.value();
|
|
786
789
|
}
|
|
787
790
|
|
|
791
|
+
// pragma MARK: std::optional<SkipToPreviousBehavior>
|
|
792
|
+
/**
|
|
793
|
+
* Specialized version of `std::optional<SkipToPreviousBehavior>`.
|
|
794
|
+
*/
|
|
795
|
+
using std__optional_SkipToPreviousBehavior_ = std::optional<SkipToPreviousBehavior>;
|
|
796
|
+
inline std::optional<SkipToPreviousBehavior> create_std__optional_SkipToPreviousBehavior_(const SkipToPreviousBehavior& value) noexcept {
|
|
797
|
+
return std::optional<SkipToPreviousBehavior>(value);
|
|
798
|
+
}
|
|
799
|
+
inline bool has_value_std__optional_SkipToPreviousBehavior_(const std::optional<SkipToPreviousBehavior>& optional) noexcept {
|
|
800
|
+
return optional.has_value();
|
|
801
|
+
}
|
|
802
|
+
inline SkipToPreviousBehavior get_std__optional_SkipToPreviousBehavior_(const std::optional<SkipToPreviousBehavior>& optional) noexcept {
|
|
803
|
+
return optional.value();
|
|
804
|
+
}
|
|
805
|
+
|
|
788
806
|
// pragma MARK: std::optional<EvictionPolicy>
|
|
789
807
|
/**
|
|
790
808
|
* Specialized version of `std::optional<EvictionPolicy>`.
|
|
@@ -126,6 +126,8 @@ namespace margelo::nitro::queueplayer { enum class ServiceReadyReason; }
|
|
|
126
126
|
namespace margelo::nitro::queueplayer { struct ShuffleResult; }
|
|
127
127
|
// Forward declaration of `SkipCapability` to properly resolve imports.
|
|
128
128
|
namespace margelo::nitro::queueplayer { struct SkipCapability; }
|
|
129
|
+
// Forward declaration of `SkipToPreviousBehavior` to properly resolve imports.
|
|
130
|
+
namespace margelo::nitro::queueplayer { enum class SkipToPreviousBehavior; }
|
|
129
131
|
// Forward declaration of `SleepTimerState` to properly resolve imports.
|
|
130
132
|
namespace margelo::nitro::queueplayer { struct SleepTimerState; }
|
|
131
133
|
// Forward declaration of `StateChangeReason` to properly resolve imports.
|
|
@@ -205,6 +207,7 @@ namespace margelo::nitro::queueplayer { struct VoiceVocabulary; }
|
|
|
205
207
|
#include "ServiceReadyReason.hpp"
|
|
206
208
|
#include "ShuffleResult.hpp"
|
|
207
209
|
#include "SkipCapability.hpp"
|
|
210
|
+
#include "SkipToPreviousBehavior.hpp"
|
|
208
211
|
#include "SleepTimerState.hpp"
|
|
209
212
|
#include "StateChangeReason.hpp"
|
|
210
213
|
#include "TrackChangeReason.hpp"
|
|
@@ -18,6 +18,8 @@ namespace margelo::nitro::queueplayer { struct PlayerConfig; }
|
|
|
18
18
|
namespace margelo::nitro::queueplayer { enum class AudioContentType; }
|
|
19
19
|
// Forward declaration of `AudioCategoryOptions` to properly resolve imports.
|
|
20
20
|
namespace margelo::nitro::queueplayer { struct AudioCategoryOptions; }
|
|
21
|
+
// Forward declaration of `SkipToPreviousBehavior` to properly resolve imports.
|
|
22
|
+
namespace margelo::nitro::queueplayer { enum class SkipToPreviousBehavior; }
|
|
21
23
|
// Forward declaration of `EvictionPolicy` to properly resolve imports.
|
|
22
24
|
namespace margelo::nitro::queueplayer { enum class EvictionPolicy; }
|
|
23
25
|
// Forward declaration of `TrackItem` to properly resolve imports.
|
|
@@ -108,6 +110,7 @@ namespace margelo::nitro::queueplayer { struct NowPlayingFormatAndroidExtras; }
|
|
|
108
110
|
#include <optional>
|
|
109
111
|
#include "AudioContentType.hpp"
|
|
110
112
|
#include "AudioCategoryOptions.hpp"
|
|
113
|
+
#include "SkipToPreviousBehavior.hpp"
|
|
111
114
|
#include "EvictionPolicy.hpp"
|
|
112
115
|
#include "TrackItem.hpp"
|
|
113
116
|
#include <vector>
|
|
@@ -18,7 +18,7 @@ public extension PlayerConfig {
|
|
|
18
18
|
/**
|
|
19
19
|
* Create a new instance of `PlayerConfig`.
|
|
20
20
|
*/
|
|
21
|
-
init(httpHeaders: Dictionary<String, String>?, userAgent: String?, placeholderArtworkUri: String?, autoRetries: Double?, retryBackoffMs: Double?, networkTimeoutMs: Double?, audioContentType: AudioContentType?, audioCategoryOptions: AudioCategoryOptions?, visualizationEnabled: Bool?, clampSeekToBuffered: Bool?, lookaheadCacheMaxSizeMb: Double?, lookaheadCacheEvictionPolicy: EvictionPolicy?, progressUpdateIntervalMs: Double?, backgroundProgressUpdateIntervalMs: Double?) {
|
|
21
|
+
init(httpHeaders: Dictionary<String, String>?, userAgent: String?, placeholderArtworkUri: String?, autoRetries: Double?, retryBackoffMs: Double?, networkTimeoutMs: Double?, audioContentType: AudioContentType?, audioCategoryOptions: AudioCategoryOptions?, visualizationEnabled: Bool?, clampSeekToBuffered: Bool?, skipToPreviousBehavior: SkipToPreviousBehavior?, lookaheadCacheMaxSizeMb: Double?, lookaheadCacheEvictionPolicy: EvictionPolicy?, progressUpdateIntervalMs: Double?, backgroundProgressUpdateIntervalMs: Double?) {
|
|
22
22
|
self.init({ () -> bridge.std__optional_std__unordered_map_std__string__std__string__ in
|
|
23
23
|
if let __unwrappedValue = httpHeaders {
|
|
24
24
|
return bridge.create_std__optional_std__unordered_map_std__string__std__string__({ () -> bridge.std__unordered_map_std__string__std__string_ in
|
|
@@ -85,6 +85,12 @@ public extension PlayerConfig {
|
|
|
85
85
|
} else {
|
|
86
86
|
return .init()
|
|
87
87
|
}
|
|
88
|
+
}(), { () -> bridge.std__optional_SkipToPreviousBehavior_ in
|
|
89
|
+
if let __unwrappedValue = skipToPreviousBehavior {
|
|
90
|
+
return bridge.create_std__optional_SkipToPreviousBehavior_(__unwrappedValue)
|
|
91
|
+
} else {
|
|
92
|
+
return .init()
|
|
93
|
+
}
|
|
88
94
|
}(), { () -> bridge.std__optional_double_ in
|
|
89
95
|
if let __unwrappedValue = lookaheadCacheMaxSizeMb {
|
|
90
96
|
return bridge.create_std__optional_double_(__unwrappedValue)
|
|
@@ -226,6 +232,11 @@ public extension PlayerConfig {
|
|
|
226
232
|
}()
|
|
227
233
|
}
|
|
228
234
|
|
|
235
|
+
@inline(__always)
|
|
236
|
+
var skipToPreviousBehavior: SkipToPreviousBehavior? {
|
|
237
|
+
return self.__skipToPreviousBehavior.value
|
|
238
|
+
}
|
|
239
|
+
|
|
229
240
|
@inline(__always)
|
|
230
241
|
var lookaheadCacheMaxSizeMb: Double? {
|
|
231
242
|
return { () -> Double? in
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// SkipToPreviousBehavior.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Represents the JS union `SkipToPreviousBehavior`, backed by a C++ enum.
|
|
10
|
+
*/
|
|
11
|
+
public typealias SkipToPreviousBehavior = margelo.nitro.queueplayer.SkipToPreviousBehavior
|
|
12
|
+
|
|
13
|
+
public extension SkipToPreviousBehavior {
|
|
14
|
+
/**
|
|
15
|
+
* Get a SkipToPreviousBehavior for the given String value, or
|
|
16
|
+
* return `nil` if the given value was invalid/unknown.
|
|
17
|
+
*/
|
|
18
|
+
init?(fromString string: String) {
|
|
19
|
+
switch string {
|
|
20
|
+
case "previous":
|
|
21
|
+
self = .previous
|
|
22
|
+
case "restart-or-previous":
|
|
23
|
+
self = .restartOrPrevious
|
|
24
|
+
default:
|
|
25
|
+
return nil
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Get the String value this SkipToPreviousBehavior represents.
|
|
31
|
+
*/
|
|
32
|
+
var stringValue: String {
|
|
33
|
+
switch self {
|
|
34
|
+
case .previous:
|
|
35
|
+
return "previous"
|
|
36
|
+
case .restartOrPrevious:
|
|
37
|
+
return "restart-or-previous"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -32,6 +32,8 @@
|
|
|
32
32
|
namespace margelo::nitro::queueplayer { enum class AudioContentType; }
|
|
33
33
|
// Forward declaration of `AudioCategoryOptions` to properly resolve imports.
|
|
34
34
|
namespace margelo::nitro::queueplayer { struct AudioCategoryOptions; }
|
|
35
|
+
// Forward declaration of `SkipToPreviousBehavior` to properly resolve imports.
|
|
36
|
+
namespace margelo::nitro::queueplayer { enum class SkipToPreviousBehavior; }
|
|
35
37
|
// Forward declaration of `EvictionPolicy` to properly resolve imports.
|
|
36
38
|
namespace margelo::nitro::queueplayer { enum class EvictionPolicy; }
|
|
37
39
|
|
|
@@ -40,6 +42,7 @@ namespace margelo::nitro::queueplayer { enum class EvictionPolicy; }
|
|
|
40
42
|
#include <optional>
|
|
41
43
|
#include "AudioContentType.hpp"
|
|
42
44
|
#include "AudioCategoryOptions.hpp"
|
|
45
|
+
#include "SkipToPreviousBehavior.hpp"
|
|
43
46
|
#include "EvictionPolicy.hpp"
|
|
44
47
|
|
|
45
48
|
namespace margelo::nitro::queueplayer {
|
|
@@ -59,6 +62,7 @@ namespace margelo::nitro::queueplayer {
|
|
|
59
62
|
std::optional<AudioCategoryOptions> audioCategoryOptions SWIFT_PRIVATE;
|
|
60
63
|
std::optional<bool> visualizationEnabled SWIFT_PRIVATE;
|
|
61
64
|
std::optional<bool> clampSeekToBuffered SWIFT_PRIVATE;
|
|
65
|
+
std::optional<SkipToPreviousBehavior> skipToPreviousBehavior SWIFT_PRIVATE;
|
|
62
66
|
std::optional<double> lookaheadCacheMaxSizeMb SWIFT_PRIVATE;
|
|
63
67
|
std::optional<EvictionPolicy> lookaheadCacheEvictionPolicy SWIFT_PRIVATE;
|
|
64
68
|
std::optional<double> progressUpdateIntervalMs SWIFT_PRIVATE;
|
|
@@ -66,7 +70,7 @@ namespace margelo::nitro::queueplayer {
|
|
|
66
70
|
|
|
67
71
|
public:
|
|
68
72
|
PlayerConfig() = default;
|
|
69
|
-
explicit PlayerConfig(std::optional<std::unordered_map<std::string, std::string>> httpHeaders, std::optional<std::string> userAgent, std::optional<std::string> placeholderArtworkUri, std::optional<double> autoRetries, std::optional<double> retryBackoffMs, std::optional<double> networkTimeoutMs, std::optional<AudioContentType> audioContentType, std::optional<AudioCategoryOptions> audioCategoryOptions, std::optional<bool> visualizationEnabled, std::optional<bool> clampSeekToBuffered, std::optional<double> lookaheadCacheMaxSizeMb, std::optional<EvictionPolicy> lookaheadCacheEvictionPolicy, std::optional<double> progressUpdateIntervalMs, std::optional<double> backgroundProgressUpdateIntervalMs): httpHeaders(httpHeaders), userAgent(userAgent), placeholderArtworkUri(placeholderArtworkUri), autoRetries(autoRetries), retryBackoffMs(retryBackoffMs), networkTimeoutMs(networkTimeoutMs), audioContentType(audioContentType), audioCategoryOptions(audioCategoryOptions), visualizationEnabled(visualizationEnabled), clampSeekToBuffered(clampSeekToBuffered), lookaheadCacheMaxSizeMb(lookaheadCacheMaxSizeMb), lookaheadCacheEvictionPolicy(lookaheadCacheEvictionPolicy), progressUpdateIntervalMs(progressUpdateIntervalMs), backgroundProgressUpdateIntervalMs(backgroundProgressUpdateIntervalMs) {}
|
|
73
|
+
explicit PlayerConfig(std::optional<std::unordered_map<std::string, std::string>> httpHeaders, std::optional<std::string> userAgent, std::optional<std::string> placeholderArtworkUri, std::optional<double> autoRetries, std::optional<double> retryBackoffMs, std::optional<double> networkTimeoutMs, std::optional<AudioContentType> audioContentType, std::optional<AudioCategoryOptions> audioCategoryOptions, std::optional<bool> visualizationEnabled, std::optional<bool> clampSeekToBuffered, std::optional<SkipToPreviousBehavior> skipToPreviousBehavior, std::optional<double> lookaheadCacheMaxSizeMb, std::optional<EvictionPolicy> lookaheadCacheEvictionPolicy, std::optional<double> progressUpdateIntervalMs, std::optional<double> backgroundProgressUpdateIntervalMs): httpHeaders(httpHeaders), userAgent(userAgent), placeholderArtworkUri(placeholderArtworkUri), autoRetries(autoRetries), retryBackoffMs(retryBackoffMs), networkTimeoutMs(networkTimeoutMs), audioContentType(audioContentType), audioCategoryOptions(audioCategoryOptions), visualizationEnabled(visualizationEnabled), clampSeekToBuffered(clampSeekToBuffered), skipToPreviousBehavior(skipToPreviousBehavior), lookaheadCacheMaxSizeMb(lookaheadCacheMaxSizeMb), lookaheadCacheEvictionPolicy(lookaheadCacheEvictionPolicy), progressUpdateIntervalMs(progressUpdateIntervalMs), backgroundProgressUpdateIntervalMs(backgroundProgressUpdateIntervalMs) {}
|
|
70
74
|
|
|
71
75
|
public:
|
|
72
76
|
friend bool operator==(const PlayerConfig& lhs, const PlayerConfig& rhs) = default;
|
|
@@ -92,6 +96,7 @@ namespace margelo::nitro {
|
|
|
92
96
|
JSIConverter<std::optional<margelo::nitro::queueplayer::AudioCategoryOptions>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "audioCategoryOptions"))),
|
|
93
97
|
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "visualizationEnabled"))),
|
|
94
98
|
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "clampSeekToBuffered"))),
|
|
99
|
+
JSIConverter<std::optional<margelo::nitro::queueplayer::SkipToPreviousBehavior>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "skipToPreviousBehavior"))),
|
|
95
100
|
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "lookaheadCacheMaxSizeMb"))),
|
|
96
101
|
JSIConverter<std::optional<margelo::nitro::queueplayer::EvictionPolicy>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "lookaheadCacheEvictionPolicy"))),
|
|
97
102
|
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "progressUpdateIntervalMs"))),
|
|
@@ -110,6 +115,7 @@ namespace margelo::nitro {
|
|
|
110
115
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "audioCategoryOptions"), JSIConverter<std::optional<margelo::nitro::queueplayer::AudioCategoryOptions>>::toJSI(runtime, arg.audioCategoryOptions));
|
|
111
116
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "visualizationEnabled"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.visualizationEnabled));
|
|
112
117
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "clampSeekToBuffered"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.clampSeekToBuffered));
|
|
118
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "skipToPreviousBehavior"), JSIConverter<std::optional<margelo::nitro::queueplayer::SkipToPreviousBehavior>>::toJSI(runtime, arg.skipToPreviousBehavior));
|
|
113
119
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "lookaheadCacheMaxSizeMb"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.lookaheadCacheMaxSizeMb));
|
|
114
120
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "lookaheadCacheEvictionPolicy"), JSIConverter<std::optional<margelo::nitro::queueplayer::EvictionPolicy>>::toJSI(runtime, arg.lookaheadCacheEvictionPolicy));
|
|
115
121
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "progressUpdateIntervalMs"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.progressUpdateIntervalMs));
|
|
@@ -134,6 +140,7 @@ namespace margelo::nitro {
|
|
|
134
140
|
if (!JSIConverter<std::optional<margelo::nitro::queueplayer::AudioCategoryOptions>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "audioCategoryOptions")))) return false;
|
|
135
141
|
if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "visualizationEnabled")))) return false;
|
|
136
142
|
if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "clampSeekToBuffered")))) return false;
|
|
143
|
+
if (!JSIConverter<std::optional<margelo::nitro::queueplayer::SkipToPreviousBehavior>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "skipToPreviousBehavior")))) return false;
|
|
137
144
|
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "lookaheadCacheMaxSizeMb")))) return false;
|
|
138
145
|
if (!JSIConverter<std::optional<margelo::nitro::queueplayer::EvictionPolicy>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "lookaheadCacheEvictionPolicy")))) return false;
|
|
139
146
|
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "progressUpdateIntervalMs")))) return false;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// SkipToPreviousBehavior.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/NitroHash.hpp>)
|
|
11
|
+
#include <NitroModules/NitroHash.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
16
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
21
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
|
|
26
|
+
namespace margelo::nitro::queueplayer {
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* An enum which can be represented as a JavaScript union (SkipToPreviousBehavior).
|
|
30
|
+
*/
|
|
31
|
+
enum class SkipToPreviousBehavior {
|
|
32
|
+
PREVIOUS SWIFT_NAME(previous) = 0,
|
|
33
|
+
RESTART_OR_PREVIOUS SWIFT_NAME(restartOrPrevious) = 1,
|
|
34
|
+
} CLOSED_ENUM;
|
|
35
|
+
|
|
36
|
+
} // namespace margelo::nitro::queueplayer
|
|
37
|
+
|
|
38
|
+
namespace margelo::nitro {
|
|
39
|
+
|
|
40
|
+
// C++ SkipToPreviousBehavior <> JS SkipToPreviousBehavior (union)
|
|
41
|
+
template <>
|
|
42
|
+
struct JSIConverter<margelo::nitro::queueplayer::SkipToPreviousBehavior> final {
|
|
43
|
+
static inline margelo::nitro::queueplayer::SkipToPreviousBehavior fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
44
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
|
|
45
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
46
|
+
case hashString("previous"): return margelo::nitro::queueplayer::SkipToPreviousBehavior::PREVIOUS;
|
|
47
|
+
case hashString("restart-or-previous"): return margelo::nitro::queueplayer::SkipToPreviousBehavior::RESTART_OR_PREVIOUS;
|
|
48
|
+
default: [[unlikely]]
|
|
49
|
+
throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum SkipToPreviousBehavior - invalid value!");
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::queueplayer::SkipToPreviousBehavior arg) {
|
|
53
|
+
switch (arg) {
|
|
54
|
+
case margelo::nitro::queueplayer::SkipToPreviousBehavior::PREVIOUS: return JSIConverter<std::string>::toJSI(runtime, "previous");
|
|
55
|
+
case margelo::nitro::queueplayer::SkipToPreviousBehavior::RESTART_OR_PREVIOUS: return JSIConverter<std::string>::toJSI(runtime, "restart-or-previous");
|
|
56
|
+
default: [[unlikely]]
|
|
57
|
+
throw std::invalid_argument("Cannot convert SkipToPreviousBehavior to JS - invalid value: "
|
|
58
|
+
+ std::to_string(static_cast<int>(arg)) + "!");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
62
|
+
if (!value.isString()) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
|
|
66
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
67
|
+
case hashString("previous"):
|
|
68
|
+
case hashString("restart-or-previous"):
|
|
69
|
+
return true;
|
|
70
|
+
default:
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
} // namespace margelo::nitro
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-queue-player",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Nitro Modules audio playback library for React Native — gapless, EQ, crossfade, automotive, voice, casting",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"types": "./lib/typescript/index.d.ts",
|
package/src/TrackPlayer.nitro.ts
CHANGED
|
@@ -306,17 +306,17 @@ export interface TrackPlayer
|
|
|
306
306
|
getCanSkipNext(): boolean;
|
|
307
307
|
/**
|
|
308
308
|
* Whether the user-facing Previous button should be enabled.
|
|
309
|
-
* Symmetric with `getCanSkipNext` —
|
|
309
|
+
* Symmetric with `getCanSkipNext` — with the default
|
|
310
|
+
* `skipToPreviousBehavior: 'previous'`, true when there's a previous
|
|
310
311
|
* track to skip to under the current repeat mode:
|
|
311
312
|
* - `'off'` and `'track'` at index 0: false (no previous, no wrap)
|
|
312
313
|
* - `'queue'`: true with an active track (wraps)
|
|
313
314
|
*
|
|
314
|
-
*
|
|
315
|
-
*
|
|
316
|
-
*
|
|
317
|
-
*
|
|
318
|
-
*
|
|
319
|
-
* not the policy.
|
|
315
|
+
* With `PlayerConfig.skipToPreviousBehavior: 'restart-or-previous'` the
|
|
316
|
+
* lib applies the standard music-player "restart when past ~3 s, else
|
|
317
|
+
* previous" model natively, and this reports `true` whenever a track is
|
|
318
|
+
* loaded (even at index 0, where past the threshold Previous restarts the
|
|
319
|
+
* current track) so the control never greys out.
|
|
320
320
|
*/
|
|
321
321
|
getCanSkipPrevious(): boolean;
|
|
322
322
|
/**
|
package/src/index.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -172,6 +172,21 @@ export interface PlayerConfig {
|
|
|
172
172
|
* Default: `false` (targets pass through unclamped).
|
|
173
173
|
*/
|
|
174
174
|
clampSeekToBuffered?: boolean;
|
|
175
|
+
/**
|
|
176
|
+
* How skip-to-previous behaves. `'previous'` (default) always goes to the
|
|
177
|
+
* previous track. `'restart-or-previous'` restarts the current track
|
|
178
|
+
* (seeks to 0) when it is past ~3 s, otherwise goes to the previous track
|
|
179
|
+
* — the standard music-player model. Applies
|
|
180
|
+
* to local playback; during cast, Previous routes to the receiver. When
|
|
181
|
+
* `'restart-or-previous'`, the Previous control is always enabled
|
|
182
|
+
* (`canSkipPrevious` reports `true` whenever a track is loaded, so the
|
|
183
|
+
* control never greys out — even on the first track, where past the
|
|
184
|
+
* threshold it restarts).
|
|
185
|
+
*
|
|
186
|
+
* Pinned per `configure()` (a fixed behavior, not a live toggle);
|
|
187
|
+
* changing it re-runs `configure()`. Default: `'previous'`.
|
|
188
|
+
*/
|
|
189
|
+
skipToPreviousBehavior?: SkipToPreviousBehavior;
|
|
175
190
|
/**
|
|
176
191
|
* Disk budget for the lookahead cache, in megabytes. Fixed at `configure()`
|
|
177
192
|
* time and cannot change at runtime — Android's Media3 `SimpleCache` fixes
|
|
@@ -339,6 +354,16 @@ export const crossfadeDurationBounds = {
|
|
|
339
354
|
*/
|
|
340
355
|
export type RepeatMode = 'off' | 'queue' | 'track';
|
|
341
356
|
|
|
357
|
+
/**
|
|
358
|
+
* How `skipToPrevious` (and the OS Previous control) behaves.
|
|
359
|
+
* - `'previous'` — always go to the previous track (the default; current
|
|
360
|
+
* behavior).
|
|
361
|
+
* - `'restart-or-previous'` — restart the current track (seek to 0) when it
|
|
362
|
+
* is past ~3 s, otherwise go to the previous track. The standard
|
|
363
|
+
* music-player model. See `PlayerConfig.skipToPreviousBehavior`.
|
|
364
|
+
*/
|
|
365
|
+
export type SkipToPreviousBehavior = 'previous' | 'restart-or-previous';
|
|
366
|
+
|
|
342
367
|
/**
|
|
343
368
|
* How the lock-screen / notification skip controls behave: skip between queue
|
|
344
369
|
* tracks (`'track'`) or jump forward/back within the current track by a fixed
|