@mustafaj/capacitor-plugin-playlist 0.9.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.
Files changed (90) hide show
  1. package/CapacitorPluginPlaylist.podspec +17 -0
  2. package/README.md +248 -0
  3. package/android/.project +34 -0
  4. package/android/build.gradle +69 -0
  5. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  6. package/android/gradle/wrapper/gradle-wrapper.properties +7 -0
  7. package/android/gradle.properties +22 -0
  8. package/android/gradlew +251 -0
  9. package/android/gradlew.bat +94 -0
  10. package/android/proguard-rules.pro +21 -0
  11. package/android/settings.gradle +2 -0
  12. package/android/src/androidTest/java/com/getcapacitor/android/ExampleInstrumentedTest.java +26 -0
  13. package/android/src/main/AndroidManifest.xml +4 -0
  14. package/android/src/main/java/org/dwbn/plugins/playlist/App.kt +19 -0
  15. package/android/src/main/java/org/dwbn/plugins/playlist/FakeR.kt +39 -0
  16. package/android/src/main/java/org/dwbn/plugins/playlist/OnStatusCallback.kt +34 -0
  17. package/android/src/main/java/org/dwbn/plugins/playlist/OnStatusReportListener.java +7 -0
  18. package/android/src/main/java/org/dwbn/plugins/playlist/PlaylistItemOptions.java +52 -0
  19. package/android/src/main/java/org/dwbn/plugins/playlist/PlaylistPlugin.kt +447 -0
  20. package/android/src/main/java/org/dwbn/plugins/playlist/RmxAudioErrorType.java +13 -0
  21. package/android/src/main/java/org/dwbn/plugins/playlist/RmxAudioPlayer.java +487 -0
  22. package/android/src/main/java/org/dwbn/plugins/playlist/RmxAudioStatusMessage.java +35 -0
  23. package/android/src/main/java/org/dwbn/plugins/playlist/RmxConstants.java +42 -0
  24. package/android/src/main/java/org/dwbn/plugins/playlist/TrackRemovalItem.java +12 -0
  25. package/android/src/main/java/org/dwbn/plugins/playlist/data/AudioTrack.kt +94 -0
  26. package/android/src/main/java/org/dwbn/plugins/playlist/manager/MediaControlsListener.kt +13 -0
  27. package/android/src/main/java/org/dwbn/plugins/playlist/manager/Options.kt +77 -0
  28. package/android/src/main/java/org/dwbn/plugins/playlist/manager/PlaylistManager.kt +308 -0
  29. package/android/src/main/java/org/dwbn/plugins/playlist/notification/PlaylistNotificationProvider.kt +26 -0
  30. package/android/src/main/java/org/dwbn/plugins/playlist/playlist/AudioApi.kt +114 -0
  31. package/android/src/main/java/org/dwbn/plugins/playlist/playlist/AudioPlaylistHandler.java +146 -0
  32. package/android/src/main/java/org/dwbn/plugins/playlist/playlist/BaseMediaApi.kt +36 -0
  33. package/android/src/main/java/org/dwbn/plugins/playlist/service/MediaImageProvider.kt +83 -0
  34. package/android/src/main/java/org/dwbn/plugins/playlist/service/MediaService.kt +98 -0
  35. package/android/src/main/res/.gitkeep +0 -0
  36. package/android/src/main/res/drawable/ic_closed_caption_white_24dp.xml +9 -0
  37. package/android/src/main/res/drawable/ic_demo_icon_adaptive.xml +15 -0
  38. package/android/src/main/res/drawable/ic_launcher_background.xml +48 -0
  39. package/android/src/main/res/drawable/ic_launcher_foreground.xml +22 -0
  40. package/android/src/main/res/drawable/ic_notification_icon.png +0 -0
  41. package/android/src/main/res/layout/bridge_layout_main.xml +15 -0
  42. package/android/src/main/res/values/colors.xml +3 -0
  43. package/android/src/main/res/values/strings.xml +3 -0
  44. package/android/src/main/res/values/styles.xml +3 -0
  45. package/android/src/test/java/com/getcapacitor/ExampleUnitTest.java +18 -0
  46. package/dist/docs.json +2071 -0
  47. package/dist/esm/Constants.d.ts +164 -0
  48. package/dist/esm/Constants.js +175 -0
  49. package/dist/esm/Constants.js.map +1 -0
  50. package/dist/esm/RmxAudioPlayer.d.ts +181 -0
  51. package/dist/esm/RmxAudioPlayer.js +344 -0
  52. package/dist/esm/RmxAudioPlayer.js.map +1 -0
  53. package/dist/esm/definitions.d.ts +78 -0
  54. package/dist/esm/definitions.js +2 -0
  55. package/dist/esm/definitions.js.map +1 -0
  56. package/dist/esm/index.d.ts +5 -0
  57. package/dist/esm/index.js +6 -0
  58. package/dist/esm/index.js.map +1 -0
  59. package/dist/esm/interfaces.d.ts +246 -0
  60. package/dist/esm/interfaces.js +2 -0
  61. package/dist/esm/interfaces.js.map +1 -0
  62. package/dist/esm/plugin.d.ts +3 -0
  63. package/dist/esm/plugin.js +13 -0
  64. package/dist/esm/plugin.js.map +1 -0
  65. package/dist/esm/utils.d.ts +15 -0
  66. package/dist/esm/utils.js +48 -0
  67. package/dist/esm/utils.js.map +1 -0
  68. package/dist/esm/web.d.ts +54 -0
  69. package/dist/esm/web.js +409 -0
  70. package/dist/esm/web.js.map +1 -0
  71. package/dist/plugin.cjs.js +993 -0
  72. package/dist/plugin.cjs.js.map +1 -0
  73. package/dist/plugin.js +996 -0
  74. package/dist/plugin.js.map +1 -0
  75. package/ios/Plugin/AVBidirectionalQueuePlayer.swift +269 -0
  76. package/ios/Plugin/AudioTrack.swift +63 -0
  77. package/ios/Plugin/Constants.swift +39 -0
  78. package/ios/Plugin/DispatchQueue.swift +47 -0
  79. package/ios/Plugin/Info.plist +24 -0
  80. package/ios/Plugin/Plugin.h +10 -0
  81. package/ios/Plugin/Plugin.m +30 -0
  82. package/ios/Plugin/Plugin.swift +208 -0
  83. package/ios/Plugin/RmxAudioPlayer.swift +1150 -0
  84. package/ios/Plugin.xcodeproj/project.pbxproj +574 -0
  85. package/ios/Plugin.xcworkspace/contents.xcworkspacedata +10 -0
  86. package/ios/Plugin.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  87. package/ios/PluginTests/Info.plist +22 -0
  88. package/ios/PluginTests/PluginTests.swift +35 -0
  89. package/ios/Podfile +16 -0
  90. package/package.json +89 -0
@@ -0,0 +1,94 @@
1
+ @rem
2
+ @rem Copyright 2015 the original author or authors.
3
+ @rem
4
+ @rem Licensed under the Apache License, Version 2.0 (the "License");
5
+ @rem you may not use this file except in compliance with the License.
6
+ @rem You may obtain a copy of the License at
7
+ @rem
8
+ @rem https://www.apache.org/licenses/LICENSE-2.0
9
+ @rem
10
+ @rem Unless required by applicable law or agreed to in writing, software
11
+ @rem distributed under the License is distributed on an "AS IS" BASIS,
12
+ @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ @rem See the License for the specific language governing permissions and
14
+ @rem limitations under the License.
15
+ @rem
16
+ @rem SPDX-License-Identifier: Apache-2.0
17
+ @rem
18
+
19
+ @if "%DEBUG%"=="" @echo off
20
+ @rem ##########################################################################
21
+ @rem
22
+ @rem Gradle startup script for Windows
23
+ @rem
24
+ @rem ##########################################################################
25
+
26
+ @rem Set local scope for the variables with windows NT shell
27
+ if "%OS%"=="Windows_NT" setlocal
28
+
29
+ set DIRNAME=%~dp0
30
+ if "%DIRNAME%"=="" set DIRNAME=.
31
+ @rem This is normally unused
32
+ set APP_BASE_NAME=%~n0
33
+ set APP_HOME=%DIRNAME%
34
+
35
+ @rem Resolve any "." and ".." in APP_HOME to make it shorter.
36
+ for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
37
+
38
+ @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
39
+ set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
40
+
41
+ @rem Find java.exe
42
+ if defined JAVA_HOME goto findJavaFromJavaHome
43
+
44
+ set JAVA_EXE=java.exe
45
+ %JAVA_EXE% -version >NUL 2>&1
46
+ if %ERRORLEVEL% equ 0 goto execute
47
+
48
+ echo. 1>&2
49
+ echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
50
+ echo. 1>&2
51
+ echo Please set the JAVA_HOME variable in your environment to match the 1>&2
52
+ echo location of your Java installation. 1>&2
53
+
54
+ goto fail
55
+
56
+ :findJavaFromJavaHome
57
+ set JAVA_HOME=%JAVA_HOME:"=%
58
+ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
59
+
60
+ if exist "%JAVA_EXE%" goto execute
61
+
62
+ echo. 1>&2
63
+ echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
64
+ echo. 1>&2
65
+ echo Please set the JAVA_HOME variable in your environment to match the 1>&2
66
+ echo location of your Java installation. 1>&2
67
+
68
+ goto fail
69
+
70
+ :execute
71
+ @rem Setup the command line
72
+
73
+ set CLASSPATH=
74
+
75
+
76
+ @rem Execute Gradle
77
+ "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
78
+
79
+ :end
80
+ @rem End local scope for the variables with windows NT shell
81
+ if %ERRORLEVEL% equ 0 goto mainEnd
82
+
83
+ :fail
84
+ rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
85
+ rem the _cmd.exe /c_ return code!
86
+ set EXIT_CODE=%ERRORLEVEL%
87
+ if %EXIT_CODE% equ 0 set EXIT_CODE=1
88
+ if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
89
+ exit /b %EXIT_CODE%
90
+
91
+ :mainEnd
92
+ if "%OS%"=="Windows_NT" endlocal
93
+
94
+ :omega
@@ -0,0 +1,21 @@
1
+ # Add project specific ProGuard rules here.
2
+ # You can control the set of applied configuration files using the
3
+ # proguardFiles setting in build.gradle.
4
+ #
5
+ # For more details, see
6
+ # http://developer.android.com/guide/developing/tools/proguard.html
7
+
8
+ # If your project uses WebView with JS, uncomment the following
9
+ # and specify the fully qualified class name to the JavaScript interface
10
+ # class:
11
+ #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12
+ # public *;
13
+ #}
14
+
15
+ # Uncomment this to preserve the line number information for
16
+ # debugging stack traces.
17
+ #-keepattributes SourceFile,LineNumberTable
18
+
19
+ # If you keep the line number information, uncomment this to
20
+ # hide the original source file name.
21
+ #-renamesourcefileattribute SourceFile
@@ -0,0 +1,2 @@
1
+ include ':capacitor-android'
2
+ project(':capacitor-android').projectDir = new File('../node_modules/@capacitor/android/capacitor')
@@ -0,0 +1,26 @@
1
+ package com.getcapacitor.android;
2
+
3
+ import static org.junit.Assert.*;
4
+
5
+ import android.content.Context;
6
+ import androidx.test.ext.junit.runners.AndroidJUnit4;
7
+ import androidx.test.platform.app.InstrumentationRegistry;
8
+ import org.junit.Test;
9
+ import org.junit.runner.RunWith;
10
+
11
+ /**
12
+ * Instrumented test, which will execute on an Android device.
13
+ *
14
+ * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
15
+ */
16
+ @RunWith(AndroidJUnit4.class)
17
+ public class ExampleInstrumentedTest {
18
+
19
+ @Test
20
+ public void useAppContext() throws Exception {
21
+ // Context of the app under test.
22
+ Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
23
+
24
+ assertEquals("com.getcapacitor.android", appContext.getPackageName());
25
+ }
26
+ }
@@ -0,0 +1,4 @@
1
+
2
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
3
+ >
4
+ </manifest>
@@ -0,0 +1,19 @@
1
+ package org.dwbn.plugins.playlist
2
+
3
+ import android.app.Application
4
+ import org.dwbn.plugins.playlist.manager.PlaylistManager
5
+
6
+ class App : Application() {
7
+ private lateinit var _playlistManager: PlaylistManager;
8
+ val playlistManager get() = _playlistManager
9
+
10
+ fun resetPlaylistManager() {
11
+ _playlistManager = PlaylistManager(this)
12
+ }
13
+
14
+ override fun onCreate() {
15
+ resetPlaylistManager()
16
+ super.onCreate()
17
+
18
+ }
19
+ }
@@ -0,0 +1,39 @@
1
+ package org.dwbn.plugins.playlist
2
+
3
+ import android.app.Activity
4
+ import android.content.Context
5
+
6
+ /**
7
+ * R replacement for PhoneGap Build.
8
+ * Code adopted from https://github.com/EddyVerbruggen/barcodescanner-lib-aar
9
+ *
10
+ * ([^.\w])R\.(\w+)\.(\w+)
11
+ * $1fakeR("$2", "$3")
12
+ *
13
+ * @author Maciej Nux Jaros
14
+ */
15
+ class FakeR {
16
+ var context: Context
17
+ private set
18
+ private var packageName: String
19
+
20
+ constructor(activity: Activity) {
21
+ context = activity.applicationContext
22
+ packageName = context.packageName
23
+ }
24
+
25
+ constructor(context: Context) {
26
+ this.context = context
27
+ packageName = context.packageName
28
+ }
29
+
30
+ fun getId(group: String?, key: String?): Int {
31
+ return context.resources.getIdentifier(key, group, packageName)
32
+ }
33
+
34
+ companion object {
35
+ fun getId(context: Context, group: String?, key: String?): Int {
36
+ return context.resources.getIdentifier(key, group, context.packageName)
37
+ }
38
+ }
39
+ }
@@ -0,0 +1,34 @@
1
+ package org.dwbn.plugins.playlist
2
+
3
+ import android.util.Log
4
+ import com.getcapacitor.JSObject
5
+ import org.json.JSONException
6
+ import org.json.JSONObject
7
+
8
+ class OnStatusCallback internal constructor(private val plugin: PlaylistPlugin) {
9
+ fun onStatus(what: RmxAudioStatusMessage, trackId: String?, param: JSONObject?) {
10
+ val data = JSObject()
11
+ val detail = JSObject()
12
+ detail.put("msgType", what.value)
13
+ detail.put("trackId", trackId)
14
+ detail.put("value", param)
15
+ data.put("action", "status")
16
+ data.put("status", detail)
17
+ Log.v(TAG, "statusChanged:$data")
18
+ plugin.emit("status", data)
19
+ }
20
+
21
+ companion object {
22
+ private const val TAG = "PlaylistStatusCallback"
23
+ fun createErrorWithCode(code: RmxAudioErrorType?, message: String?): JSONObject {
24
+ val error = JSONObject()
25
+ try {
26
+ error.put("code", code)
27
+ error.put("message", message ?: "")
28
+ } catch (e: JSONException) {
29
+ Log.e(TAG, "Exception while raising onStatus: ", e)
30
+ }
31
+ return error
32
+ }
33
+ }
34
+ }
@@ -0,0 +1,7 @@
1
+ package org.dwbn.plugins.playlist;
2
+ import org.json.JSONObject;
3
+
4
+ public interface OnStatusReportListener {
5
+ void onError(RmxAudioErrorType errorCode, String trackId, String message);
6
+ void onStatus(RmxAudioStatusMessage what, String trackId, JSONObject param);
7
+ }
@@ -0,0 +1,52 @@
1
+ package org.dwbn.plugins.playlist;
2
+
3
+ import org.json.JSONException;
4
+ import org.json.JSONObject;
5
+
6
+ public class PlaylistItemOptions {
7
+ private JSONObject options;
8
+
9
+ private boolean retainPosition = false;
10
+ private long playFromPosition = -1L;
11
+ private String playFromId = null;
12
+ private boolean startPaused = true;
13
+
14
+ PlaylistItemOptions(JSONObject optionsObj) {
15
+ this.options = optionsObj;
16
+ if (this.options == null) {
17
+ this.options = new JSONObject();
18
+ }
19
+
20
+ this.retainPosition = this.options.optBoolean("retainPosition", false);
21
+ this.startPaused = this.options.optBoolean("startPaused", false);
22
+ this.playFromId = this.options.optString("playFromId", null);
23
+
24
+ try {
25
+ playFromPosition = (long)this.options.getDouble("playFromPosition") * 1000L;
26
+ } catch (JSONException ex) {
27
+ playFromPosition = -1L;
28
+ }
29
+ }
30
+
31
+ PlaylistItemOptions(boolean retainPosition, long playFromPosition, boolean startPaused) {
32
+ this.startPaused = startPaused;
33
+ this.retainPosition = retainPosition;
34
+ this.playFromPosition = playFromPosition;
35
+ }
36
+
37
+ public boolean getStartPaused() {
38
+ return startPaused;
39
+ }
40
+
41
+ public boolean getRetainPosition() {
42
+ return retainPosition;
43
+ }
44
+
45
+ public long getPlayFromPosition() {
46
+ return playFromPosition;
47
+ }
48
+
49
+ public String getPlayFromId() {
50
+ return playFromId;
51
+ }
52
+ }