cordova-plugin-media3 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/.travis.yml +0 -0
- package/CODE_OF_CONDUCT.md +46 -0
- package/CONTRIBUTING.md +4 -0
- package/LICENSE +21 -0
- package/README.md +297 -0
- package/package.json +32 -0
- package/plugin.xml +61 -0
- package/src/android/CallbackResponse.java +53 -0
- package/src/android/Configuration.java +104 -0
- package/src/android/DeviceDetector.java +132 -0
- package/src/android/LayoutProvider.java +218 -0
- package/src/android/Payload.java +361 -0
- package/src/android/Player.java +1063 -0
- package/src/android/Plugin.java +287 -0
- package/src/res/drawable/fastforward.png +0 -0
- package/src/res/drawable/next.png +0 -0
- package/src/res/drawable/pause.png +0 -0
- package/src/res/drawable/play.png +0 -0
- package/src/res/drawable/previous.png +0 -0
- package/src/res/drawable/rewind.png +0 -0
- package/src/res/layout/exo_playback_control_view.xml +121 -0
- package/src/res/layout/exo_rounded_corners.xml +6 -0
- package/src/res/layout/exo_simple_player_view.xml +58 -0
- package/src/res/values/constants.xml +23 -0
- package/src/res/values/ids.xml +9 -0
- package/src/res/values/styles.xml +52 -0
- package/www/exoplayer.js +91 -0
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
/*
|
|
2
|
+
The MIT License (MIT)
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2017 Nedim Cholich
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
package co.frontyard.cordova.plugin.exoplayer;
|
|
25
|
+
|
|
26
|
+
import android.graphics.Color;
|
|
27
|
+
import android.net.*;
|
|
28
|
+
import android.view.ViewGroup;
|
|
29
|
+
import org.apache.cordova.*;
|
|
30
|
+
import org.json.*;
|
|
31
|
+
|
|
32
|
+
public class Plugin extends CordovaPlugin {
|
|
33
|
+
private Player player;
|
|
34
|
+
|
|
35
|
+
@Override
|
|
36
|
+
public boolean execute(final String action, final JSONArray data, final CallbackContext callbackContext) throws JSONException {
|
|
37
|
+
try {
|
|
38
|
+
final Plugin self = this;
|
|
39
|
+
if (action.equals("show")) {
|
|
40
|
+
cordova.getActivity().runOnUiThread(new Runnable() {
|
|
41
|
+
public void run() {
|
|
42
|
+
if (self.player != null) {
|
|
43
|
+
self.player.close();
|
|
44
|
+
}
|
|
45
|
+
JSONObject params = data.optJSONObject(0);
|
|
46
|
+
self.player = new Player(new Configuration(params), cordova.getActivity(), callbackContext, webView);
|
|
47
|
+
webView.getView().setBackgroundColor(Color.TRANSPARENT);
|
|
48
|
+
self.player.createPlayer();
|
|
49
|
+
new CallbackResponse(callbackContext).send(PluginResult.Status.NO_RESULT, true);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
else if (action.equals("setStream")) {
|
|
55
|
+
if (self.player == null) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
final String url = data.optString(0, null);
|
|
59
|
+
final JSONObject controller = data.optJSONObject(1);
|
|
60
|
+
cordova.getActivity().runOnUiThread(new Runnable() {
|
|
61
|
+
public void run() {
|
|
62
|
+
self.player.setStream(Uri.parse(url), controller);
|
|
63
|
+
new CallbackResponse(callbackContext).send(PluginResult.Status.NO_RESULT, true);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
else if (action.equals("playPause")) {
|
|
69
|
+
if (self.player == null) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
cordova.getActivity().runOnUiThread(new Runnable() {
|
|
73
|
+
public void run() {
|
|
74
|
+
self.player.playPause();
|
|
75
|
+
new CallbackResponse(callbackContext).send(PluginResult.Status.NO_RESULT, true);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
else if (action.equals("stop")) {
|
|
82
|
+
if (self.player == null) {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
cordova.getActivity().runOnUiThread(new Runnable() {
|
|
86
|
+
public void run() {
|
|
87
|
+
self.player.stop();
|
|
88
|
+
new CallbackResponse(callbackContext).send(PluginResult.Status.NO_RESULT, true);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
else if (action.equals("seekTo")) {
|
|
95
|
+
if (self.player == null) {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
final long seekTo = data.optLong(0, 0);
|
|
99
|
+
cordova.getActivity().runOnUiThread(new Runnable() {
|
|
100
|
+
public void run() {
|
|
101
|
+
JSONObject payload = self.player.seekTo(seekTo);
|
|
102
|
+
new CallbackResponse(callbackContext).send(PluginResult.Status.OK, payload, true);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
else if (action.equals("seekBy")) {
|
|
108
|
+
if (self.player == null) {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
final long seekBy = data.optLong(0, 0);
|
|
112
|
+
cordova.getActivity().runOnUiThread(new Runnable() {
|
|
113
|
+
public void run() {
|
|
114
|
+
JSONObject payload = self.player.seekBy(seekBy);
|
|
115
|
+
new CallbackResponse(callbackContext).send(PluginResult.Status.OK, payload, true);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
else if (action.equals("getState")) {
|
|
121
|
+
if (self.player == null) {
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
cordova.getThreadPool().execute(new Runnable() {
|
|
125
|
+
public void run() {
|
|
126
|
+
JSONObject response = self.player.getPlayerState();
|
|
127
|
+
new CallbackResponse(callbackContext).send(PluginResult.Status.OK, response, false);
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
return true;
|
|
131
|
+
}
|
|
132
|
+
else if (action.equals("showController")) {
|
|
133
|
+
if (self.player == null) {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
cordova.getActivity().runOnUiThread(new Runnable() {
|
|
137
|
+
public void run() {
|
|
138
|
+
self.player.showController();
|
|
139
|
+
new CallbackResponse(callbackContext).send(PluginResult.Status.NO_RESULT, true);
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
else if (action.equals("hideController")) {
|
|
145
|
+
if (self.player == null) {
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
cordova.getActivity().runOnUiThread(new Runnable() {
|
|
149
|
+
public void run() {
|
|
150
|
+
self.player.hideController();
|
|
151
|
+
new CallbackResponse(callbackContext).send(PluginResult.Status.NO_RESULT, true);
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
return true;
|
|
155
|
+
}
|
|
156
|
+
else if (action.equals("setController")) {
|
|
157
|
+
if (self.player == null) {
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
final JSONObject controller = data.optJSONObject(0);
|
|
161
|
+
cordova.getActivity().runOnUiThread(new Runnable() {
|
|
162
|
+
public void run() {
|
|
163
|
+
self.player.setController(controller);
|
|
164
|
+
new CallbackResponse(callbackContext).send(PluginResult.Status.NO_RESULT, true);
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
return true;
|
|
168
|
+
}
|
|
169
|
+
else if (action.equals("close")) {
|
|
170
|
+
if (self.player == null) {
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
cordova.getActivity().runOnUiThread(new Runnable() {
|
|
174
|
+
public void run() {
|
|
175
|
+
self.player.close();
|
|
176
|
+
new CallbackResponse(callbackContext).send(PluginResult.Status.OK, false);
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
return true;
|
|
180
|
+
}
|
|
181
|
+
else if (action.equals("setZIndex")) {
|
|
182
|
+
cordova.getActivity().runOnUiThread(new Runnable() {
|
|
183
|
+
public void run() {
|
|
184
|
+
if (self.player != null) {
|
|
185
|
+
int zIndex = data.optInt(0);
|
|
186
|
+
self.player.setZIndex(zIndex);
|
|
187
|
+
new CallbackResponse(callbackContext).send(PluginResult.Status.NO_RESULT, true);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
return true;
|
|
192
|
+
|
|
193
|
+
}
|
|
194
|
+
else if (action.equals("play")) {
|
|
195
|
+
if (self.player == null) {
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
cordova.getActivity().runOnUiThread(new Runnable() {
|
|
199
|
+
public void run() {
|
|
200
|
+
self.player.play();
|
|
201
|
+
new CallbackResponse(callbackContext).send(PluginResult.Status.NO_RESULT, true);
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
return true;
|
|
205
|
+
}
|
|
206
|
+
else if (action.equals("pause")) {
|
|
207
|
+
if (self.player == null) {
|
|
208
|
+
return false;
|
|
209
|
+
}
|
|
210
|
+
cordova.getActivity().runOnUiThread(new Runnable() {
|
|
211
|
+
public void run() {
|
|
212
|
+
self.player.pause();
|
|
213
|
+
new CallbackResponse(callbackContext).send(PluginResult.Status.NO_RESULT, true);
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
return true;
|
|
217
|
+
} else if (action.equals("setSubtitleTrack")) {
|
|
218
|
+
if (self.player == null) {
|
|
219
|
+
return false;
|
|
220
|
+
}
|
|
221
|
+
final int trackIndex = data.optInt(0);
|
|
222
|
+
cordova.getActivity().runOnUiThread(new Runnable() {
|
|
223
|
+
public void run() {
|
|
224
|
+
JSONObject response = self.player.setSubtitleTrack(trackIndex);
|
|
225
|
+
new CallbackResponse(callbackContext).send(PluginResult.Status.OK, response, true);
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
return true;
|
|
229
|
+
} else if (action.equals("setAudioTrack")) {
|
|
230
|
+
if (self.player == null) {
|
|
231
|
+
return false;
|
|
232
|
+
}
|
|
233
|
+
final int trackIndex = data.optInt(0);
|
|
234
|
+
cordova.getActivity().runOnUiThread(new Runnable() {
|
|
235
|
+
public void run() {
|
|
236
|
+
JSONObject response = self.player.setAudioTrack(trackIndex);
|
|
237
|
+
new CallbackResponse(callbackContext).send(PluginResult.Status.OK, response, true);
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
return true;
|
|
241
|
+
} else if (action.equals("subTitleOff")) {
|
|
242
|
+
if (self.player == null) {
|
|
243
|
+
return false;
|
|
244
|
+
}
|
|
245
|
+
cordova.getActivity().runOnUiThread(new Runnable() {
|
|
246
|
+
public void run() {
|
|
247
|
+
JSONObject response = self.player.subTitleOff();
|
|
248
|
+
new CallbackResponse(callbackContext).send(PluginResult.Status.OK, response, true);
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
return true;
|
|
252
|
+
|
|
253
|
+
} else if (action.equals("setSubtitleStyle")) {
|
|
254
|
+
if (self.player == null) {
|
|
255
|
+
return false;
|
|
256
|
+
}
|
|
257
|
+
final String textColor = data.optString(0, "#FFFFFF"); // Default white text
|
|
258
|
+
final String backgroundColor = data.optString(1, "#80000000"); // Default semi-transparent black
|
|
259
|
+
final String edgeColor = data.optString(2, "#000000"); // Default black edge
|
|
260
|
+
final int edgeType = data.optInt(3, 1); // Default outline edge
|
|
261
|
+
cordova.getActivity().runOnUiThread(new Runnable() {
|
|
262
|
+
public void run() {
|
|
263
|
+
JSONObject response = self.player.setSubtitleStyle(textColor, backgroundColor, edgeColor, edgeType);
|
|
264
|
+
new CallbackResponse(callbackContext).send(PluginResult.Status.OK, response, true);
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
return true;
|
|
268
|
+
} else if (action.equals("isTV")) {
|
|
269
|
+
cordova.getActivity().runOnUiThread(new Runnable() {
|
|
270
|
+
public void run() {
|
|
271
|
+
JSONObject response = DeviceDetector.isTV(cordova.getActivity());
|
|
272
|
+
new CallbackResponse(callbackContext).send(PluginResult.Status.OK, response, true);
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
return true;
|
|
276
|
+
} else {
|
|
277
|
+
new CallbackResponse(callbackContext).send(PluginResult.Status.INVALID_ACTION, false);
|
|
278
|
+
return false;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
catch (Exception e) {
|
|
282
|
+
new CallbackResponse(callbackContext).send(PluginResult.Status.JSON_EXCEPTION, false);
|
|
283
|
+
return false;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
3
|
+
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
4
|
+
android:layout_width="match_parent"
|
|
5
|
+
android:layout_height="match_parent"
|
|
6
|
+
android:layout_gravity="center"
|
|
7
|
+
android:layoutDirection="ltr"
|
|
8
|
+
android:orientation="vertical">
|
|
9
|
+
|
|
10
|
+
<!-- Control button bar -->
|
|
11
|
+
<LinearLayout
|
|
12
|
+
android:id="@id/exo_buttons"
|
|
13
|
+
android:layout_width="wrap_content"
|
|
14
|
+
android:layout_height="wrap_content"
|
|
15
|
+
android:layout_gravity="center"
|
|
16
|
+
android:gravity="center"
|
|
17
|
+
android:orientation="horizontal">
|
|
18
|
+
|
|
19
|
+
<ImageButton android:id="@id/exo_rew"
|
|
20
|
+
style="@style/Exo.Rewind"/>
|
|
21
|
+
<ImageButton android:id="@id/exo_play"
|
|
22
|
+
style="@style/Exo.Play"/>
|
|
23
|
+
<ImageButton android:id="@id/exo_pause"
|
|
24
|
+
style="@style/Exo.Pause"/>
|
|
25
|
+
<ImageButton android:id="@id/exo_ffwd"
|
|
26
|
+
style="@style/Exo.FastForward"/>
|
|
27
|
+
</LinearLayout>
|
|
28
|
+
|
|
29
|
+
<!-- Buttom info bar -->
|
|
30
|
+
<LinearLayout
|
|
31
|
+
android:layout_width="match_parent"
|
|
32
|
+
android:layout_height="wrap_content"
|
|
33
|
+
android:layout_gravity="bottom"
|
|
34
|
+
android:gravity="center_vertical"
|
|
35
|
+
android:orientation="horizontal"
|
|
36
|
+
android:background="@layout/exo_rounded_corners"
|
|
37
|
+
android:layout_marginLeft="48dp"
|
|
38
|
+
android:layout_marginBottom="48dp"
|
|
39
|
+
android:layout_marginRight="48dp"
|
|
40
|
+
android:paddingTop="@dimen/padding"
|
|
41
|
+
android:paddingBottom="@dimen/padding"
|
|
42
|
+
android:paddingLeft="@dimen/padding"
|
|
43
|
+
android:paddingRight="@dimen/padding">
|
|
44
|
+
|
|
45
|
+
<!-- Left -->
|
|
46
|
+
<ImageView android:id="@id/exo_image"
|
|
47
|
+
android:layout_width="wrap_content"
|
|
48
|
+
android:layout_height="wrap_content"
|
|
49
|
+
android:gravity="center_vertical"
|
|
50
|
+
android:maxHeight="86dp"
|
|
51
|
+
android:maxWidth="144dp"
|
|
52
|
+
android:adjustViewBounds="true"
|
|
53
|
+
android:scaleType="centerInside"/>
|
|
54
|
+
<!-- Right -->
|
|
55
|
+
<LinearLayout
|
|
56
|
+
android:layout_width="match_parent"
|
|
57
|
+
android:layout_height="wrap_content"
|
|
58
|
+
android:layout_gravity="bottom"
|
|
59
|
+
android:gravity="center_vertical"
|
|
60
|
+
android:orientation="vertical"
|
|
61
|
+
android:paddingLeft="@dimen/padding">
|
|
62
|
+
|
|
63
|
+
<!-- First line -->
|
|
64
|
+
<TextView android:id="@id/exo_title"
|
|
65
|
+
android:layout_width="wrap_content"
|
|
66
|
+
android:layout_height="wrap_content"
|
|
67
|
+
android:layout_gravity="center_vertical"
|
|
68
|
+
android:gravity="center_vertical"
|
|
69
|
+
android:textSize="28dp"
|
|
70
|
+
android:textStyle="bold"
|
|
71
|
+
android:includeFontPadding="false"
|
|
72
|
+
android:textColor="@color/foreground_color"/>
|
|
73
|
+
|
|
74
|
+
<!-- Second line -->
|
|
75
|
+
<TextView android:id="@id/exo_subtitle"
|
|
76
|
+
android:layout_width="wrap_content"
|
|
77
|
+
android:layout_height="wrap_content"
|
|
78
|
+
android:layout_gravity="center_vertical"
|
|
79
|
+
android:gravity="center_vertical"
|
|
80
|
+
android:textSize="20dp"
|
|
81
|
+
android:textStyle="bold"
|
|
82
|
+
android:includeFontPadding="false"
|
|
83
|
+
android:textColor="@color/foreground_color"/>
|
|
84
|
+
|
|
85
|
+
<!-- Third line -->
|
|
86
|
+
<LinearLayout android:id="@id/exo_timebar"
|
|
87
|
+
android:layout_width="match_parent"
|
|
88
|
+
android:layout_height="wrap_content"
|
|
89
|
+
android:paddingTop="8dp"
|
|
90
|
+
android:gravity="center_vertical"
|
|
91
|
+
android:orientation="horizontal">
|
|
92
|
+
|
|
93
|
+
<TextView android:id="@id/exo_position"
|
|
94
|
+
android:layout_width="wrap_content"
|
|
95
|
+
android:layout_height="wrap_content"
|
|
96
|
+
android:textSize="20dp"
|
|
97
|
+
android:textStyle="bold"
|
|
98
|
+
android:paddingRight="8dp"
|
|
99
|
+
android:includeFontPadding="false"
|
|
100
|
+
android:textColor="@color/foreground_color"/>
|
|
101
|
+
|
|
102
|
+
<com.google.android.exoplayer2.ui.DefaultTimeBar
|
|
103
|
+
android:id="@id/exo_progress"
|
|
104
|
+
android:layout_width="0dp"
|
|
105
|
+
android:layout_weight="1"
|
|
106
|
+
android:layout_height="26dp"
|
|
107
|
+
app:played_color="@color/foreground_color"
|
|
108
|
+
app:buffered_color="#FFBEBEBE"/>
|
|
109
|
+
|
|
110
|
+
<TextView android:id="@id/exo_duration"
|
|
111
|
+
android:layout_width="wrap_content"
|
|
112
|
+
android:layout_height="wrap_content"
|
|
113
|
+
android:textSize="20dp"
|
|
114
|
+
android:textStyle="bold"
|
|
115
|
+
android:paddingLeft="8dp"
|
|
116
|
+
android:includeFontPadding="false"
|
|
117
|
+
android:textColor="@color/foreground_color"/>
|
|
118
|
+
</LinearLayout>
|
|
119
|
+
</LinearLayout>
|
|
120
|
+
</LinearLayout>
|
|
121
|
+
</FrameLayout>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
|
3
|
+
<solid android:color="@color/background_color"/>
|
|
4
|
+
<corners android:radius="5dp"/>
|
|
5
|
+
<padding android:left="0dp" android:top="0dp" android:right="0dp" android:bottom="0dp"/>
|
|
6
|
+
</shape>
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<!-- Copyright (C) 2016 The Android Open Source Project
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
-->
|
|
16
|
+
<merge xmlns:android="http://schemas.android.com/apk/res/android">
|
|
17
|
+
|
|
18
|
+
<com.google.android.exoplayer2.ui.AspectRatioFrameLayout
|
|
19
|
+
android:id="@id/exo_content_frame"
|
|
20
|
+
android:layout_width="match_parent"
|
|
21
|
+
android:layout_height="match_parent"
|
|
22
|
+
android:layout_gravity="center">
|
|
23
|
+
|
|
24
|
+
<!-- Video surface will be inserted as the first child of the content frame. -->
|
|
25
|
+
<View android:id="@id/exo_shutter"
|
|
26
|
+
android:layout_width="match_parent"
|
|
27
|
+
android:layout_height="match_parent"
|
|
28
|
+
android:background="@android:color/black"/>
|
|
29
|
+
|
|
30
|
+
<ImageView android:id="@id/exo_artwork"
|
|
31
|
+
android:layout_width="match_parent"
|
|
32
|
+
android:layout_height="match_parent"
|
|
33
|
+
android:scaleType="fitXY"/>
|
|
34
|
+
|
|
35
|
+
<com.google.android.exoplayer2.ui.SubtitleView
|
|
36
|
+
android:id="@id/exo_subtitles"
|
|
37
|
+
android:layout_width="match_parent"
|
|
38
|
+
android:layout_height="match_parent"/>
|
|
39
|
+
|
|
40
|
+
</com.google.android.exoplayer2.ui.AspectRatioFrameLayout>
|
|
41
|
+
|
|
42
|
+
<View android:id="@id/exo_controller_placeholder"
|
|
43
|
+
android:layout_width="match_parent"
|
|
44
|
+
android:layout_height="match_parent"/>
|
|
45
|
+
|
|
46
|
+
<ProgressBar
|
|
47
|
+
android:id="@+id/exo_buffering"
|
|
48
|
+
style="?android:attr/progressBarStyleHorizontal"
|
|
49
|
+
android:layout_width="fill_parent"
|
|
50
|
+
android:layout_height="wrap_content"
|
|
51
|
+
android:layout_gravity="top"
|
|
52
|
+
android:layout_alignParentTop="true"
|
|
53
|
+
android:paddingTop="0dp"
|
|
54
|
+
android:max="100"
|
|
55
|
+
android:indeterminateTint="@color/accent_color"
|
|
56
|
+
android:indeterminateTintMode="src_in"
|
|
57
|
+
android:indeterminate="true"/>
|
|
58
|
+
</merge>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<!-- Copyright (C) 2016 The Android Open Source Project
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
-->
|
|
16
|
+
<resources>
|
|
17
|
+
<dimen name="button_width">96dp</dimen>
|
|
18
|
+
<dimen name="button_height">96dp</dimen>
|
|
19
|
+
<dimen name="padding">12dp</dimen>
|
|
20
|
+
<color name="background_color">#cc000000</color>
|
|
21
|
+
<color name="foreground_color">@android:color/white</color>
|
|
22
|
+
<color name="accent_color">#3399CC</color>
|
|
23
|
+
</resources>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<resources>
|
|
3
|
+
<item name="exo_buttons" type="id"/>
|
|
4
|
+
<item name="exo_image" type="id"/>
|
|
5
|
+
<item name="exo_title" type="id"/>
|
|
6
|
+
<item name="exo_subtitle" type="id"/>
|
|
7
|
+
<item name="exo_timebar" type="id"/>
|
|
8
|
+
<item name="exo_buffering" type="id"/>
|
|
9
|
+
</resources>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<!-- Copyright (C) 2016 The Android Open Source Project
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
-->
|
|
16
|
+
<resources>
|
|
17
|
+
<style name="Exo">
|
|
18
|
+
<item name="android:background">@null</item>
|
|
19
|
+
<item name="android:layout_width">@dimen/button_width</item>
|
|
20
|
+
<item name="android:layout_height">@dimen/button_height</item>
|
|
21
|
+
<item name="android:padding">@dimen/padding</item>
|
|
22
|
+
<item name="android:layout_marginLeft">@dimen/padding</item>
|
|
23
|
+
<item name="android:layout_marginRight">@dimen/padding</item>
|
|
24
|
+
<item name="android:layout_gravity">center</item>
|
|
25
|
+
<item name="android:adjustViewBounds">true</item>
|
|
26
|
+
<item name="android:scaleType">centerInside</item>
|
|
27
|
+
</style>
|
|
28
|
+
|
|
29
|
+
<style name="Exo.Previous">
|
|
30
|
+
<item name="android:src">@drawable/previous</item>
|
|
31
|
+
</style>
|
|
32
|
+
|
|
33
|
+
<style name="Exo.Next">
|
|
34
|
+
<item name="android:src">@drawable/next</item>
|
|
35
|
+
</style>
|
|
36
|
+
|
|
37
|
+
<style name="Exo.FastForward">
|
|
38
|
+
<item name="android:src">@drawable/fastforward</item>
|
|
39
|
+
</style>
|
|
40
|
+
|
|
41
|
+
<style name="Exo.Rewind">
|
|
42
|
+
<item name="android:src">@drawable/rewind</item>
|
|
43
|
+
</style>
|
|
44
|
+
|
|
45
|
+
<style name="Exo.Play">
|
|
46
|
+
<item name="android:src">@drawable/play</item>
|
|
47
|
+
</style>
|
|
48
|
+
|
|
49
|
+
<style name="Exo.Pause">
|
|
50
|
+
<item name="android:src">@drawable/pause</item>
|
|
51
|
+
</style>
|
|
52
|
+
</resources>
|
package/www/exoplayer.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/*global cordova, module*/
|
|
2
|
+
/*
|
|
3
|
+
The MIT License (MIT)
|
|
4
|
+
|
|
5
|
+
Copyright (c) 2017 Nedim Cholich
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
in the Software without restriction, including without limitation the rights
|
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
module.exports = {
|
|
26
|
+
show: function (parameters, successCallback, errorCallback) {
|
|
27
|
+
cordova.exec(successCallback, errorCallback, "ExoPlayer", "show", [parameters]);
|
|
28
|
+
},
|
|
29
|
+
setStream: function (url, controller, successCallback, errorCallback) {
|
|
30
|
+
cordova.exec(successCallback, errorCallback, "ExoPlayer", "setStream", [url, controller]);
|
|
31
|
+
},
|
|
32
|
+
playPause: function (successCallback, errorCallback) {
|
|
33
|
+
cordova.exec(successCallback, errorCallback, "ExoPlayer", "playPause", []);
|
|
34
|
+
},
|
|
35
|
+
stop: function (successCallback, errorCallback) {
|
|
36
|
+
cordova.exec(successCallback, errorCallback, "ExoPlayer", "stop", []);
|
|
37
|
+
},
|
|
38
|
+
seekTo: function (milliseconds, successCallback, errorCallback) {
|
|
39
|
+
cordova.exec(successCallback, errorCallback, "ExoPlayer", "seekTo", [milliseconds]);
|
|
40
|
+
},
|
|
41
|
+
seekBy: function (milliseconds, successCallback, errorCallback) {
|
|
42
|
+
cordova.exec(successCallback, errorCallback, "ExoPlayer", "seekBy", [milliseconds]);
|
|
43
|
+
},
|
|
44
|
+
getState: function (successCallback, errorCallback) {
|
|
45
|
+
cordova.exec(successCallback, errorCallback, "ExoPlayer", "getState", []);
|
|
46
|
+
},
|
|
47
|
+
showController: function (successCallback, errorCallback) {
|
|
48
|
+
cordova.exec(successCallback, errorCallback, "ExoPlayer", "showController", []);
|
|
49
|
+
},
|
|
50
|
+
hideController: function (successCallback, errorCallback) {
|
|
51
|
+
cordova.exec(successCallback, errorCallback, "ExoPlayer", "hideController", []);
|
|
52
|
+
},
|
|
53
|
+
setController: function (controller, successCallback, errorCallback) {
|
|
54
|
+
cordova.exec(successCallback, errorCallback, "ExoPlayer", "setController", [controller]);
|
|
55
|
+
},
|
|
56
|
+
close: function (successCallback, errorCallback) {
|
|
57
|
+
cordova.exec(successCallback, errorCallback, "ExoPlayer", "close", []);
|
|
58
|
+
},
|
|
59
|
+
setZIndex: function(zIndex, successCallback, errorCallback) {
|
|
60
|
+
cordova.exec(successCallback, errorCallback, "ExoPlayer", "setZIndex", [zIndex]);
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
play: function (successCallback, errorCallback) {
|
|
64
|
+
cordova.exec(successCallback, errorCallback, "ExoPlayer", "play", []);
|
|
65
|
+
},
|
|
66
|
+
pause: function (successCallback, errorCallback) {
|
|
67
|
+
cordova.exec(successCallback, errorCallback, "ExoPlayer", "pause", []);
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
subTitleOff: function (successCallback, errorCallback) {
|
|
71
|
+
cordova.exec(successCallback, errorCallback, "ExoPlayer", "subTitleOff", []);
|
|
72
|
+
},
|
|
73
|
+
setSubtitleTrack: function (index, successCallback, errorCallback) {
|
|
74
|
+
cordova.exec(successCallback, errorCallback, "ExoPlayer", "setSubtitleTrack", [index]);
|
|
75
|
+
},
|
|
76
|
+
setAudioTrack: function (index, successCallback, errorCallback) {
|
|
77
|
+
cordova.exec(successCallback, errorCallback, "ExoPlayer", "setAudioTrack", [index]);
|
|
78
|
+
},
|
|
79
|
+
setSubtitleStyle: function (subtitle_color, subtitle_background, edgeColor, edgeType, successCallback, errorCallback) {
|
|
80
|
+
cordova.exec(successCallback, errorCallback, "ExoPlayer", "setSubtitleStyle", [subtitle_color, subtitle_background, edgeColor, edgeType]);
|
|
81
|
+
},
|
|
82
|
+
isTV: function (successCallback, errorCallback) {
|
|
83
|
+
cordova.exec(successCallback, errorCallback, "ExoPlayer", "isTV", []);
|
|
84
|
+
},
|
|
85
|
+
getDuration: function (successCallback, errorCallback) {
|
|
86
|
+
cordova.exec(successCallback, errorCallback, "ExoPlayer", "getDuration", []);
|
|
87
|
+
},
|
|
88
|
+
getCurrentPosition: function (successCallback, errorCallback) {
|
|
89
|
+
cordova.exec(successCallback, errorCallback, "ExoPlayer", "getCurrentPosition", []);
|
|
90
|
+
}
|
|
91
|
+
};
|