str-native-video-player 1.0.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/Package.swift +28 -0
- package/README.md +232 -0
- package/StrNativeVideoPlayer.podspec +17 -0
- package/android/build.gradle +59 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/com/strtv/app/STRTV.java +430 -0
- package/android/src/main/java/com/strtv/app/STRTVPlugin.java +236 -0
- package/android/src/main/java/com/strtv/app/VideoPlayer.java +163 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/docs.json +202 -0
- package/dist/esm/IndexedDBInterface.d.ts +48 -0
- package/dist/esm/IndexedDBInterface.js +215 -0
- package/dist/esm/IndexedDBInterface.js.map +1 -0
- package/dist/esm/VideoCacheCoordinator.d.ts +21 -0
- package/dist/esm/VideoCacheCoordinator.js +74 -0
- package/dist/esm/VideoCacheCoordinator.js.map +1 -0
- package/dist/esm/definitions.d.ts +116 -0
- package/dist/esm/definitions.js +2 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/web.d.ts +72 -0
- package/dist/esm/web.js +110 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +411 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +414 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Sources/STRTVPlugin/STRTV.swift +8 -0
- package/ios/Sources/STRTVPlugin/STRTVPlugin.swift +23 -0
- package/ios/Tests/STRTVPluginTests/STRTVPluginTests.swift +15 -0
- package/package.json +80 -0
package/Package.swift
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// swift-tools-version: 5.9
|
|
2
|
+
import PackageDescription
|
|
3
|
+
|
|
4
|
+
let package = Package(
|
|
5
|
+
name: "StrNativeVideoPlayer",
|
|
6
|
+
platforms: [.iOS(.v14)],
|
|
7
|
+
products: [
|
|
8
|
+
.library(
|
|
9
|
+
name: "StrNativeVideoPlayer",
|
|
10
|
+
targets: ["STRTVPlugin"])
|
|
11
|
+
],
|
|
12
|
+
dependencies: [
|
|
13
|
+
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "7.0.0")
|
|
14
|
+
],
|
|
15
|
+
targets: [
|
|
16
|
+
.target(
|
|
17
|
+
name: "STRTVPlugin",
|
|
18
|
+
dependencies: [
|
|
19
|
+
.product(name: "Capacitor", package: "capacitor-swift-pm"),
|
|
20
|
+
.product(name: "Cordova", package: "capacitor-swift-pm")
|
|
21
|
+
],
|
|
22
|
+
path: "ios/Sources/STRTVPlugin"),
|
|
23
|
+
.testTarget(
|
|
24
|
+
name: "STRTVPluginTests",
|
|
25
|
+
dependencies: ["STRTVPlugin"],
|
|
26
|
+
path: "ios/Tests/STRTVPluginTests")
|
|
27
|
+
]
|
|
28
|
+
)
|
package/README.md
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
# str-native-video-player
|
|
2
|
+
|
|
3
|
+
Allows for native video player functionality, fetching and storing videos from a CDN, switching between the playback of these videos with cross fade and preloading functionality
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install str-native-video-player
|
|
9
|
+
npx cap sync
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## API
|
|
13
|
+
|
|
14
|
+
<docgen-index>
|
|
15
|
+
|
|
16
|
+
* [`echo(...)`](#echo)
|
|
17
|
+
* [`play_video(...)`](#play_video)
|
|
18
|
+
* [`pause_video(...)`](#pause_video)
|
|
19
|
+
* [`resume_video(...)`](#resume_video)
|
|
20
|
+
* [`stop_video(...)`](#stop_video)
|
|
21
|
+
* [`seek_video(...)`](#seek_video)
|
|
22
|
+
* [`is_video_playing()`](#is_video_playing)
|
|
23
|
+
* [`preload_video(...)`](#preload_video)
|
|
24
|
+
* [`list_cached_videos()`](#list_cached_videos)
|
|
25
|
+
* [`evict_videos(...)`](#evict_videos)
|
|
26
|
+
* [`get_storage_stats()`](#get_storage_stats)
|
|
27
|
+
* [`set_max_cache_size(...)`](#set_max_cache_size)
|
|
28
|
+
|
|
29
|
+
</docgen-index>
|
|
30
|
+
|
|
31
|
+
<docgen-api>
|
|
32
|
+
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
|
|
33
|
+
|
|
34
|
+
### echo(...)
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
echo(options: { value: string; }) => Promise<{ value: string; }>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Simple echo for testing connectivity.
|
|
41
|
+
|
|
42
|
+
| Param | Type |
|
|
43
|
+
| ------------- | ------------------------------- |
|
|
44
|
+
| **`options`** | <code>{ value: string; }</code> |
|
|
45
|
+
|
|
46
|
+
**Returns:** <code>Promise<{ value: string; }></code>
|
|
47
|
+
|
|
48
|
+
--------------------
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
### play_video(...)
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
play_video(options: { uuid: string; url?: string; loop?: boolean; video_player?: any; }) => Promise<{ success: boolean; }>
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Core video playback method.
|
|
58
|
+
|
|
59
|
+
Plays a video identified by `uuid`. If it is not cached locally, it will stream from `url`
|
|
60
|
+
while simultaneously caching it for future playback.
|
|
61
|
+
|
|
62
|
+
| Param | Type |
|
|
63
|
+
| ------------- | -------------------------------------------------------------------------------- |
|
|
64
|
+
| **`options`** | <code>{ uuid: string; url?: string; loop?: boolean; video_player?: any; }</code> |
|
|
65
|
+
|
|
66
|
+
**Returns:** <code>Promise<{ success: boolean; }></code>
|
|
67
|
+
|
|
68
|
+
--------------------
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
### pause_video(...)
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
pause_video(options: { video_player?: any; }) => Promise<{ success: boolean; }>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Pauses the currently playing video.
|
|
78
|
+
|
|
79
|
+
| Param | Type |
|
|
80
|
+
| ------------- | ------------------------------------ |
|
|
81
|
+
| **`options`** | <code>{ video_player?: any; }</code> |
|
|
82
|
+
|
|
83
|
+
**Returns:** <code>Promise<{ success: boolean; }></code>
|
|
84
|
+
|
|
85
|
+
--------------------
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
### resume_video(...)
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
resume_video(options: { video_player?: any; }) => Promise<{ success: boolean; }>
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Resumes the currently playing video.
|
|
95
|
+
|
|
96
|
+
| Param | Type |
|
|
97
|
+
| ------------- | ------------------------------------ |
|
|
98
|
+
| **`options`** | <code>{ video_player?: any; }</code> |
|
|
99
|
+
|
|
100
|
+
**Returns:** <code>Promise<{ success: boolean; }></code>
|
|
101
|
+
|
|
102
|
+
--------------------
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
### stop_video(...)
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
stop_video(options: { video_player?: any; }) => Promise<{ success: boolean; }>
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Stops the currently playing video.
|
|
112
|
+
|
|
113
|
+
| Param | Type |
|
|
114
|
+
| ------------- | ------------------------------------ |
|
|
115
|
+
| **`options`** | <code>{ video_player?: any; }</code> |
|
|
116
|
+
|
|
117
|
+
**Returns:** <code>Promise<{ success: boolean; }></code>
|
|
118
|
+
|
|
119
|
+
--------------------
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
### seek_video(...)
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
seek_video(options: { position_ms: number; video_player?: any; }) => Promise<{ success: boolean; }>
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Seeks the currently playing video to a specific position in milliseconds.
|
|
129
|
+
|
|
130
|
+
| Param | Type |
|
|
131
|
+
| ------------- | --------------------------------------------------------- |
|
|
132
|
+
| **`options`** | <code>{ position_ms: number; video_player?: any; }</code> |
|
|
133
|
+
|
|
134
|
+
**Returns:** <code>Promise<{ success: boolean; }></code>
|
|
135
|
+
|
|
136
|
+
--------------------
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
### is_video_playing()
|
|
140
|
+
|
|
141
|
+
```typescript
|
|
142
|
+
is_video_playing() => Promise<{ playing: boolean; }>
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Returns whether a video is currently playing.
|
|
146
|
+
|
|
147
|
+
**Returns:** <code>Promise<{ playing: boolean; }></code>
|
|
148
|
+
|
|
149
|
+
--------------------
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
### preload_video(...)
|
|
153
|
+
|
|
154
|
+
```typescript
|
|
155
|
+
preload_video(options: { uuid: string; url: string; }) => Promise<{ success: boolean; }>
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Preload a video into local storage (without playing).
|
|
159
|
+
Will fetch and cache the video to speed up future playback.
|
|
160
|
+
|
|
161
|
+
Optional: should respect max cache size and apply LRU eviction.
|
|
162
|
+
|
|
163
|
+
| Param | Type |
|
|
164
|
+
| ------------- | ------------------------------------------- |
|
|
165
|
+
| **`options`** | <code>{ uuid: string; url: string; }</code> |
|
|
166
|
+
|
|
167
|
+
**Returns:** <code>Promise<{ success: boolean; }></code>
|
|
168
|
+
|
|
169
|
+
--------------------
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
### list_cached_videos()
|
|
173
|
+
|
|
174
|
+
```typescript
|
|
175
|
+
list_cached_videos() => Promise<{ value: { uuid: string; url: string; size_bytes: number; last_accessed: number; }[]; }>
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
List all currently cached videos with metadata.
|
|
179
|
+
|
|
180
|
+
**Returns:** <code>Promise<{ value: { uuid: string; url: string; size_bytes: number; last_accessed: number; }[]; }></code>
|
|
181
|
+
|
|
182
|
+
--------------------
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
### evict_videos(...)
|
|
186
|
+
|
|
187
|
+
```typescript
|
|
188
|
+
evict_videos(options: { uuids: string[]; }) => Promise<{ success: boolean; }>
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Evict specific videos from cache manually.
|
|
192
|
+
|
|
193
|
+
| Param | Type |
|
|
194
|
+
| ------------- | --------------------------------- |
|
|
195
|
+
| **`options`** | <code>{ uuids: string[]; }</code> |
|
|
196
|
+
|
|
197
|
+
**Returns:** <code>Promise<{ success: boolean; }></code>
|
|
198
|
+
|
|
199
|
+
--------------------
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
### get_storage_stats()
|
|
203
|
+
|
|
204
|
+
```typescript
|
|
205
|
+
get_storage_stats() => Promise<{ available_bytes: number; total_bytes: number; used_bytes_videos: number; used_bytes_app: number; }>
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
Get cache/storage statistics.
|
|
209
|
+
|
|
210
|
+
**Returns:** <code>Promise<{ available_bytes: number; total_bytes: number; used_bytes_videos: number; used_bytes_app: number; }></code>
|
|
211
|
+
|
|
212
|
+
--------------------
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
### set_max_cache_size(...)
|
|
216
|
+
|
|
217
|
+
```typescript
|
|
218
|
+
set_max_cache_size(options: { max_bytes: number; }) => Promise<{ success: boolean; }>
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
Set maximum cache size for videos.
|
|
222
|
+
When exceeded, LRU eviction should occur automatically.
|
|
223
|
+
|
|
224
|
+
| Param | Type |
|
|
225
|
+
| ------------- | ----------------------------------- |
|
|
226
|
+
| **`options`** | <code>{ max_bytes: number; }</code> |
|
|
227
|
+
|
|
228
|
+
**Returns:** <code>Promise<{ success: boolean; }></code>
|
|
229
|
+
|
|
230
|
+
--------------------
|
|
231
|
+
|
|
232
|
+
</docgen-api>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = 'StrNativeVideoPlayer'
|
|
7
|
+
s.version = package['version']
|
|
8
|
+
s.summary = package['description']
|
|
9
|
+
s.license = package['license']
|
|
10
|
+
s.homepage = package['repository']['url']
|
|
11
|
+
s.author = package['author']
|
|
12
|
+
s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
|
|
13
|
+
s.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
14
|
+
s.ios.deployment_target = '14.0'
|
|
15
|
+
s.dependency 'Capacitor'
|
|
16
|
+
s.swift_version = '5.1'
|
|
17
|
+
end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
ext {
|
|
2
|
+
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
|
|
3
|
+
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.7.0'
|
|
4
|
+
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.2.1'
|
|
5
|
+
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.6.1'
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
buildscript {
|
|
9
|
+
repositories {
|
|
10
|
+
google()
|
|
11
|
+
mavenCentral()
|
|
12
|
+
}
|
|
13
|
+
dependencies {
|
|
14
|
+
classpath 'com.android.tools.build:gradle:8.7.2'
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
apply plugin: 'com.android.library'
|
|
19
|
+
|
|
20
|
+
android {
|
|
21
|
+
namespace "com.strtv.app"
|
|
22
|
+
compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 35
|
|
23
|
+
defaultConfig {
|
|
24
|
+
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 24
|
|
25
|
+
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 35
|
|
26
|
+
versionCode 1
|
|
27
|
+
versionName "1.0"
|
|
28
|
+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
29
|
+
}
|
|
30
|
+
buildTypes {
|
|
31
|
+
release {
|
|
32
|
+
minifyEnabled false
|
|
33
|
+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
lintOptions {
|
|
37
|
+
abortOnError false
|
|
38
|
+
}
|
|
39
|
+
compileOptions {
|
|
40
|
+
sourceCompatibility JavaVersion.VERSION_17
|
|
41
|
+
targetCompatibility JavaVersion.VERSION_17
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
repositories {
|
|
46
|
+
google()
|
|
47
|
+
mavenCentral()
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
dependencies {
|
|
52
|
+
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
53
|
+
implementation project(':capacitor-android')
|
|
54
|
+
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
55
|
+
implementation 'androidx.media3:media3-exoplayer:1.8.0'
|
|
56
|
+
testImplementation "junit:junit:$junitVersion"
|
|
57
|
+
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
58
|
+
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
59
|
+
}
|