@capgo/capacitor-video-player 7.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/CapgoCapacitorVideoPlayer.podspec +17 -0
- package/Package.swift +28 -0
- package/README.md +431 -0
- package/android/build.gradle +72 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/java/com/capgo/videoplayer/FullscreenExoPlayerFragment.java +1406 -0
- package/android/src/main/java/com/capgo/videoplayer/Notifications/MyRunnable.java +21 -0
- package/android/src/main/java/com/capgo/videoplayer/Notifications/NotificationCenter.java +61 -0
- package/android/src/main/java/com/capgo/videoplayer/PickerVideo/AdapterVideoList.java +47 -0
- package/android/src/main/java/com/capgo/videoplayer/PickerVideo/ModelVideo.java +49 -0
- package/android/src/main/java/com/capgo/videoplayer/PickerVideo/PickerVideoFragment.java +116 -0
- package/android/src/main/java/com/capgo/videoplayer/PickerVideo/VideoRecyclerViewHolder.java +65 -0
- package/android/src/main/java/com/capgo/videoplayer/Utilities/FilesUtils.java +38 -0
- package/android/src/main/java/com/capgo/videoplayer/Utilities/FragmentUtils.java +32 -0
- package/android/src/main/java/com/capgo/videoplayer/VideoPlayer.java +71 -0
- package/android/src/main/java/com/capgo/videoplayer/VideoPlayerPlugin.java +1239 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/android/src/main/res/drawable/bg_round_rect_white_50.xml +9 -0
- package/android/src/main/res/drawable/bg_rounded_rectangle_white_corner_rounded.xml +10 -0
- package/android/src/main/res/drawable/exo_close_btn.xml +12 -0
- package/android/src/main/res/drawable/gradient_transparent_middle.xml +12 -0
- package/android/src/main/res/drawable/ic_arrow_left.xml +5 -0
- package/android/src/main/res/drawable/ic_baseline_lq.xml +7 -0
- package/android/src/main/res/drawable/ic_exo_icon_fastforward.xml +35 -0
- package/android/src/main/res/drawable/ic_exo_icon_pause.xml +26 -0
- package/android/src/main/res/drawable/ic_exo_icon_play.xml +36 -0
- package/android/src/main/res/drawable/ic_exo_icon_rewind.xml +35 -0
- package/android/src/main/res/drawable/ic_expand.xml +5 -0
- package/android/src/main/res/drawable/ic_fit.xml +5 -0
- package/android/src/main/res/drawable/ic_image_background.xml +12 -0
- package/android/src/main/res/drawable/ic_img_16_9_background.xml +10 -0
- package/android/src/main/res/drawable/ic_img_9_16_background.xml +10 -0
- package/android/src/main/res/drawable/ic_outline_lock.xml +5 -0
- package/android/src/main/res/drawable/ic_outline_lock_open.xml +5 -0
- package/android/src/main/res/drawable/ic_pip_white.xml +5 -0
- package/android/src/main/res/drawable/ic_views.xml +18 -0
- package/android/src/main/res/drawable/ic_zoom.xml +5 -0
- package/android/src/main/res/layout/bridge_layout_main.xml +15 -0
- package/android/src/main/res/layout/exo_playback_control_view.xml +287 -0
- package/android/src/main/res/layout/exoplayer_layout_youtube.xml +361 -0
- package/android/src/main/res/layout/fragment_fs_exoplayer.xml +50 -0
- package/android/src/main/res/layout/fragment_picker_video.xml +21 -0
- package/android/src/main/res/layout/row_video.xml +76 -0
- package/android/src/main/res/values/colors.xml +14 -0
- package/android/src/main/res/values/strings.xml +3 -0
- package/android/src/main/res/values/styles.xml +3 -0
- package/dist/docs.json +686 -0
- package/dist/esm/definitions.d.ts +307 -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-utils/video-types.d.ts +4 -0
- package/dist/esm/web-utils/video-types.js +9 -0
- package/dist/esm/web-utils/video-types.js.map +1 -0
- package/dist/esm/web-utils/videoplayer.d.ts +30 -0
- package/dist/esm/web-utils/videoplayer.js +323 -0
- package/dist/esm/web-utils/videoplayer.js.map +1 -0
- package/dist/esm/web.d.ts +121 -0
- package/dist/esm/web.js +675 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +1019 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +1021 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Sources/VideoPlayerPlugin/VideoPlayer.swift +8 -0
- package/ios/Sources/VideoPlayerPlugin/VideoPlayerPlugin.swift +23 -0
- package/ios/Tests/VideoPlayerPluginTests/VideoPlayerPluginTests.swift +15 -0
- package/package.json +85 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
package com.capgo.videoplayer.Notifications;
|
|
2
|
+
|
|
3
|
+
import java.util.Map;
|
|
4
|
+
|
|
5
|
+
public class MyRunnable implements Runnable {
|
|
6
|
+
|
|
7
|
+
private Map<String, Object> info;
|
|
8
|
+
|
|
9
|
+
public Map<String, Object> getInfo() {
|
|
10
|
+
return this.info;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
public void setInfo(Map<String, Object> _info) {
|
|
14
|
+
this.info = _info;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@Override
|
|
18
|
+
public void run() {}
|
|
19
|
+
|
|
20
|
+
public void run(Map<String, Object> info) {}
|
|
21
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
package com.capgo.videoplayer.Notifications;
|
|
2
|
+
|
|
3
|
+
import java.util.ArrayList;
|
|
4
|
+
import java.util.HashMap;
|
|
5
|
+
import java.util.Iterator;
|
|
6
|
+
import java.util.Map;
|
|
7
|
+
|
|
8
|
+
public class NotificationCenter {
|
|
9
|
+
|
|
10
|
+
//static reference for singleton
|
|
11
|
+
private static NotificationCenter _instance;
|
|
12
|
+
|
|
13
|
+
private HashMap<String, ArrayList<MyRunnable>> registeredObjects;
|
|
14
|
+
|
|
15
|
+
//default c'tor for singleton
|
|
16
|
+
private NotificationCenter() {
|
|
17
|
+
registeredObjects = new HashMap<String, ArrayList<MyRunnable>>();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//returning the reference
|
|
21
|
+
public static synchronized NotificationCenter defaultCenter() {
|
|
22
|
+
if (_instance == null) _instance = new NotificationCenter();
|
|
23
|
+
return _instance;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public synchronized void addMethodForNotification(String notificationName, MyRunnable r) {
|
|
27
|
+
ArrayList<MyRunnable> list = registeredObjects.get(notificationName);
|
|
28
|
+
if (list == null) {
|
|
29
|
+
list = new ArrayList<MyRunnable>();
|
|
30
|
+
registeredObjects.put(notificationName, list);
|
|
31
|
+
}
|
|
32
|
+
list.add(r);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public synchronized void removeMethodForNotification(String notificationName, MyRunnable r) {
|
|
36
|
+
ArrayList<MyRunnable> list = registeredObjects.get(notificationName);
|
|
37
|
+
if (list != null) {
|
|
38
|
+
list.remove(r);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public synchronized void removeAllNotifications() {
|
|
43
|
+
for (Iterator<Map.Entry<String, ArrayList<MyRunnable>>> entry = registeredObjects.entrySet().iterator(); entry.hasNext(); ) {
|
|
44
|
+
Map.Entry<String, ArrayList<MyRunnable>> e = entry.next();
|
|
45
|
+
String key = e.getKey();
|
|
46
|
+
ArrayList<MyRunnable> value = e.getValue();
|
|
47
|
+
removeMethodForNotification(key, value.get(0));
|
|
48
|
+
entry.remove();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
public synchronized void postNotification(String notificationName, Map<String, Object> _info) {
|
|
53
|
+
ArrayList<MyRunnable> list = registeredObjects.get(notificationName);
|
|
54
|
+
if (list != null) {
|
|
55
|
+
for (MyRunnable r : new ArrayList<>(list)) {
|
|
56
|
+
r.setInfo(_info);
|
|
57
|
+
r.run();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
package com.capgo.videoplayer.PickerVideo;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import android.util.Log;
|
|
5
|
+
import android.view.LayoutInflater;
|
|
6
|
+
import android.view.ViewGroup;
|
|
7
|
+
import androidx.annotation.NonNull;
|
|
8
|
+
import androidx.recyclerview.widget.RecyclerView;
|
|
9
|
+
import com.capgo.videoplayer.R;
|
|
10
|
+
import java.util.ArrayList;
|
|
11
|
+
|
|
12
|
+
//public class AdapterVideoList extends RecyclerView.Adapter<AdapterVideoList.MyViewHolder> {
|
|
13
|
+
public class AdapterVideoList extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
|
14
|
+
|
|
15
|
+
private static final String TAG = AdapterVideoList.class.getName();
|
|
16
|
+
|
|
17
|
+
ArrayList<ModelVideo> videosList;
|
|
18
|
+
Context context;
|
|
19
|
+
PickerVideoFragment parentFragment;
|
|
20
|
+
|
|
21
|
+
public AdapterVideoList(Context context, PickerVideoFragment parent, ArrayList<ModelVideo> videosList) {
|
|
22
|
+
this.context = context;
|
|
23
|
+
this.videosList = videosList;
|
|
24
|
+
this.parentFragment = parent;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@NonNull
|
|
28
|
+
@Override
|
|
29
|
+
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int viewType) {
|
|
30
|
+
return new VideoRecyclerViewHolder(LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.row_video, viewGroup, false));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@Override
|
|
34
|
+
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int position) {
|
|
35
|
+
((VideoRecyclerViewHolder) viewHolder).onBind(parentFragment, videosList.get(position));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@Override
|
|
39
|
+
public long getItemId(int position) {
|
|
40
|
+
return super.getItemId(position);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@Override
|
|
44
|
+
public int getItemCount() {
|
|
45
|
+
return videosList.size();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
package com.capgo.videoplayer.PickerVideo;
|
|
2
|
+
|
|
3
|
+
import android.net.Uri;
|
|
4
|
+
|
|
5
|
+
public class ModelVideo {
|
|
6
|
+
|
|
7
|
+
long id;
|
|
8
|
+
Uri data;
|
|
9
|
+
String title, duration;
|
|
10
|
+
|
|
11
|
+
public ModelVideo(long id, Uri data, String title, String duration) {
|
|
12
|
+
this.id = id;
|
|
13
|
+
this.data = data;
|
|
14
|
+
this.title = title;
|
|
15
|
+
this.duration = duration;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
public long getId() {
|
|
19
|
+
return id;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public void setId(long id) {
|
|
23
|
+
this.id = id;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public Uri getData() {
|
|
27
|
+
return data;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public void setData(Uri data) {
|
|
31
|
+
this.data = data;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public String getTitle() {
|
|
35
|
+
return title;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public void setTitle(String title) {
|
|
39
|
+
this.title = title;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public String getDuration() {
|
|
43
|
+
return duration;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
public void setDuration(String duration) {
|
|
47
|
+
this.duration = duration;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
package com.capgo.videoplayer.PickerVideo;
|
|
2
|
+
|
|
3
|
+
//import android.app.Fragment;
|
|
4
|
+
import android.content.ContentUris;
|
|
5
|
+
import android.content.Context;
|
|
6
|
+
import android.database.Cursor;
|
|
7
|
+
import android.net.Uri;
|
|
8
|
+
import android.os.Build;
|
|
9
|
+
import android.os.Bundle;
|
|
10
|
+
import android.provider.MediaStore;
|
|
11
|
+
import android.util.Log;
|
|
12
|
+
import android.view.LayoutInflater;
|
|
13
|
+
import android.view.View;
|
|
14
|
+
import android.view.ViewGroup;
|
|
15
|
+
import androidx.annotation.RequiresApi;
|
|
16
|
+
import androidx.fragment.app.Fragment;
|
|
17
|
+
import androidx.recyclerview.widget.GridLayoutManager;
|
|
18
|
+
import androidx.recyclerview.widget.RecyclerView;
|
|
19
|
+
import com.capgo.videoplayer.Notifications.NotificationCenter;
|
|
20
|
+
import com.capgo.videoplayer.R;
|
|
21
|
+
import java.util.ArrayList;
|
|
22
|
+
import java.util.HashMap;
|
|
23
|
+
import java.util.Locale;
|
|
24
|
+
import java.util.Map;
|
|
25
|
+
|
|
26
|
+
public class PickerVideoFragment extends Fragment {
|
|
27
|
+
|
|
28
|
+
private static final String TAG = PickerVideoFragment.class.getName();
|
|
29
|
+
|
|
30
|
+
private View view;
|
|
31
|
+
private RecyclerView recyclerView;
|
|
32
|
+
RecyclerView.LayoutManager recyclerViewLayoutManager;
|
|
33
|
+
private Context context;
|
|
34
|
+
private ArrayList<ModelVideo> videosList = new ArrayList<ModelVideo>();
|
|
35
|
+
private AdapterVideoList adapterVideoList;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Create Fragment View
|
|
39
|
+
* @param inflater
|
|
40
|
+
* @param container
|
|
41
|
+
* @param savedInstanceState
|
|
42
|
+
* @return View
|
|
43
|
+
*/
|
|
44
|
+
@SuppressWarnings("serial")
|
|
45
|
+
@RequiresApi(api = Build.VERSION_CODES.M)
|
|
46
|
+
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
|
47
|
+
context = container.getContext();
|
|
48
|
+
// Inflate the layout for this fragment
|
|
49
|
+
view = inflater.inflate(R.layout.fragment_picker_video, container, false);
|
|
50
|
+
loadVideos();
|
|
51
|
+
Log.v(TAG, "*** videosList.size() " + videosList.size());
|
|
52
|
+
if (videosList.size() > 0) {
|
|
53
|
+
recyclerView = view.findViewById(R.id.recyclerView_videos);
|
|
54
|
+
recyclerViewLayoutManager = new GridLayoutManager(context, 2, GridLayoutManager.VERTICAL, false);
|
|
55
|
+
recyclerView.setLayoutManager(recyclerViewLayoutManager);
|
|
56
|
+
adapterVideoList = new AdapterVideoList(context, this, videosList);
|
|
57
|
+
recyclerView.setAdapter(adapterVideoList);
|
|
58
|
+
} else {
|
|
59
|
+
Map<String, Object> info = new HashMap<String, Object>() {
|
|
60
|
+
{
|
|
61
|
+
long videoId = -1;
|
|
62
|
+
put("videoId", videoId);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
Log.v(TAG, "*** info " + info.toString());
|
|
66
|
+
NotificationCenter.defaultCenter().postNotification("videoPathInternalReady", info);
|
|
67
|
+
}
|
|
68
|
+
return view;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
private void loadVideos() {
|
|
72
|
+
String[] projection = {
|
|
73
|
+
MediaStore.Video.Media._ID,
|
|
74
|
+
MediaStore.Video.Media.DISPLAY_NAME,
|
|
75
|
+
MediaStore.Video.Media.DURATION,
|
|
76
|
+
MediaStore.Video.Media.DATE_ADDED
|
|
77
|
+
};
|
|
78
|
+
String sortOrder = MediaStore.Video.Media.DATE_ADDED + " DESC";
|
|
79
|
+
Uri collection;
|
|
80
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
|
81
|
+
collection = MediaStore.Video.Media.getContentUri(MediaStore.VOLUME_EXTERNAL);
|
|
82
|
+
} else {
|
|
83
|
+
collection = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
Cursor cursor = getActivity().getApplication().getContentResolver().query(collection, projection, null, null, sortOrder);
|
|
87
|
+
if (cursor != null) {
|
|
88
|
+
int idColumn = cursor.getColumnIndexOrThrow(MediaStore.Video.Media._ID);
|
|
89
|
+
int titleColumn = cursor.getColumnIndexOrThrow(MediaStore.Video.Media.DISPLAY_NAME);
|
|
90
|
+
int durationColumn = cursor.getColumnIndexOrThrow(MediaStore.Video.Media.DURATION);
|
|
91
|
+
|
|
92
|
+
while (cursor.moveToNext()) {
|
|
93
|
+
long id = cursor.getLong(idColumn);
|
|
94
|
+
String title = cursor.getString(titleColumn);
|
|
95
|
+
int duration = cursor.getInt(durationColumn);
|
|
96
|
+
|
|
97
|
+
Uri data = ContentUris.withAppendedId(collection, id);
|
|
98
|
+
|
|
99
|
+
String duration_formatted;
|
|
100
|
+
int sec = (duration / 1000) % 60;
|
|
101
|
+
int min = (duration / (1000 * 60)) % 60;
|
|
102
|
+
int hrs = duration / (1000 * 60 * 60);
|
|
103
|
+
|
|
104
|
+
if (hrs == 0) {
|
|
105
|
+
duration_formatted = String.valueOf(min).concat(":".concat(String.format(Locale.UK, "%02d", sec)));
|
|
106
|
+
} else {
|
|
107
|
+
duration_formatted = String.valueOf(hrs).concat(
|
|
108
|
+
":".concat(String.format(Locale.UK, "%02d", min).concat(":".concat(String.format(Locale.UK, "%02d", sec))))
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
Log.v(TAG, "**** video " + id + " " + title + " " + duration_formatted + " ****");
|
|
112
|
+
videosList.add(new ModelVideo(id, data, title, duration_formatted));
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
package com.capgo.videoplayer.PickerVideo;
|
|
2
|
+
|
|
3
|
+
import android.util.Log;
|
|
4
|
+
import android.view.View;
|
|
5
|
+
import android.widget.ImageView;
|
|
6
|
+
import android.widget.TextView;
|
|
7
|
+
import androidx.annotation.NonNull;
|
|
8
|
+
import androidx.recyclerview.widget.RecyclerView;
|
|
9
|
+
import com.capgo.videoplayer.Notifications.NotificationCenter;
|
|
10
|
+
import com.capgo.videoplayer.R;
|
|
11
|
+
import com.squareup.picasso.Picasso;
|
|
12
|
+
import java.util.HashMap;
|
|
13
|
+
import java.util.Map;
|
|
14
|
+
|
|
15
|
+
public class VideoRecyclerViewHolder extends RecyclerView.ViewHolder {
|
|
16
|
+
|
|
17
|
+
private static final String TAG = VideoRecyclerViewHolder.class.getName();
|
|
18
|
+
ImageView tv_thumbnail;
|
|
19
|
+
TextView tv_title, tv_duration;
|
|
20
|
+
View parent;
|
|
21
|
+
|
|
22
|
+
public VideoRecyclerViewHolder(@NonNull View itemView) {
|
|
23
|
+
super(itemView);
|
|
24
|
+
parent = itemView;
|
|
25
|
+
tv_title = itemView.findViewById(R.id.tv_title);
|
|
26
|
+
tv_duration = itemView.findViewById(R.id.tv_duration);
|
|
27
|
+
tv_thumbnail = itemView.findViewById(R.id.tv_thumbnail);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public void onBind(PickerVideoFragment parentFragment, final ModelVideo modelVideo) {
|
|
31
|
+
parent.setTag(this);
|
|
32
|
+
|
|
33
|
+
tv_title.setText(modelVideo.getTitle());
|
|
34
|
+
tv_duration.setText(modelVideo.getDuration());
|
|
35
|
+
|
|
36
|
+
parentFragment
|
|
37
|
+
.getActivity()
|
|
38
|
+
.runOnUiThread(
|
|
39
|
+
new Runnable() {
|
|
40
|
+
@Override
|
|
41
|
+
public void run() {
|
|
42
|
+
Picasso.get().load(modelVideo.getData()).placeholder(R.drawable.ic_image_background).fit().into(tv_thumbnail);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
parent.setOnClickListener(
|
|
48
|
+
new View.OnClickListener() {
|
|
49
|
+
@SuppressWarnings("serial")
|
|
50
|
+
@Override
|
|
51
|
+
public void onClick(View v) {
|
|
52
|
+
Map<String, Object> info = new HashMap<String, Object>() {
|
|
53
|
+
{
|
|
54
|
+
long videoId = modelVideo.getId();
|
|
55
|
+
Log.v(TAG, "**** in onBindViewHolder videoId: " + videoId + " ****");
|
|
56
|
+
put("videoId", videoId);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
NotificationCenter.defaultCenter().postNotification("videoPathInternalReady", info);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
package com.capgo.videoplayer.Utilities;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import java.io.File;
|
|
5
|
+
|
|
6
|
+
public class FilesUtils {
|
|
7
|
+
|
|
8
|
+
private final Context context;
|
|
9
|
+
|
|
10
|
+
public FilesUtils(Context context) {
|
|
11
|
+
this.context = context;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
public String getFilePath(String url) {
|
|
15
|
+
if (url.startsWith("file:///")) {
|
|
16
|
+
return url;
|
|
17
|
+
}
|
|
18
|
+
String path = null;
|
|
19
|
+
String http = url.substring(0, 4);
|
|
20
|
+
if (http.equals("http")) {
|
|
21
|
+
path = url;
|
|
22
|
+
} else {
|
|
23
|
+
if (url.substring(0, 11).equals("application")) {
|
|
24
|
+
String filesDir = context.getFilesDir() + "/";
|
|
25
|
+
path = filesDir + url.substring(url.lastIndexOf("files/") + 6);
|
|
26
|
+
File file = new File(path);
|
|
27
|
+
if (!file.exists()) {
|
|
28
|
+
path = null;
|
|
29
|
+
}
|
|
30
|
+
} else if (url.contains("assets")) {
|
|
31
|
+
path = "file:///android_asset/" + url;
|
|
32
|
+
} else {
|
|
33
|
+
path = null;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return path;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
package com.capgo.videoplayer.Utilities;
|
|
2
|
+
|
|
3
|
+
import androidx.fragment.app.Fragment;
|
|
4
|
+
import androidx.fragment.app.FragmentManager;
|
|
5
|
+
import androidx.fragment.app.FragmentTransaction;
|
|
6
|
+
import com.getcapacitor.Bridge;
|
|
7
|
+
|
|
8
|
+
public class FragmentUtils {
|
|
9
|
+
|
|
10
|
+
private Bridge bridge;
|
|
11
|
+
|
|
12
|
+
public FragmentUtils(Bridge bridge) {
|
|
13
|
+
this.bridge = bridge;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
public void loadFragment(Fragment vpFragment, int frameLayoutId) {
|
|
17
|
+
// create a FragmentManager
|
|
18
|
+
FragmentManager fm = bridge.getActivity().getSupportFragmentManager();
|
|
19
|
+
// create a FragmentTransaction to begin the transaction and replace the Fragment
|
|
20
|
+
FragmentTransaction fragmentTransaction = fm.beginTransaction();
|
|
21
|
+
// replace the FrameLayout with new Fragment
|
|
22
|
+
fragmentTransaction.replace(frameLayoutId, vpFragment);
|
|
23
|
+
fragmentTransaction.commit(); // save the changes
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public void removeFragment(/*VideoPlayerFragmentFullscreenExoPlayer*/ Fragment vpFragment) {
|
|
27
|
+
FragmentManager fm = bridge.getActivity().getSupportFragmentManager();
|
|
28
|
+
FragmentTransaction fragmentTransaction = fm.beginTransaction();
|
|
29
|
+
fragmentTransaction.remove(vpFragment);
|
|
30
|
+
fragmentTransaction.commit();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
package com.capgo.videoplayer;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import com.capgo.videoplayer.PickerVideo.PickerVideoFragment;
|
|
5
|
+
import com.getcapacitor.JSObject;
|
|
6
|
+
|
|
7
|
+
public class VideoPlayer {
|
|
8
|
+
|
|
9
|
+
private final Context context;
|
|
10
|
+
|
|
11
|
+
VideoPlayer(Context context) {
|
|
12
|
+
this.context = context;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
public String echo(String value) {
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public FullscreenExoPlayerFragment createFullScreenFragment(
|
|
20
|
+
String videoPath,
|
|
21
|
+
Float videoRate,
|
|
22
|
+
Boolean exitOnEnd,
|
|
23
|
+
Boolean loopOnEnd,
|
|
24
|
+
Boolean pipEnabled,
|
|
25
|
+
Boolean bkModeEnabled,
|
|
26
|
+
Boolean showControls,
|
|
27
|
+
String displayMode,
|
|
28
|
+
String subTitle,
|
|
29
|
+
String language,
|
|
30
|
+
JSObject subTitleOptions,
|
|
31
|
+
JSObject headers,
|
|
32
|
+
String title,
|
|
33
|
+
String smallTitle,
|
|
34
|
+
String accentColor,
|
|
35
|
+
Boolean chromecast,
|
|
36
|
+
String artwork,
|
|
37
|
+
Boolean isTV,
|
|
38
|
+
String playerId,
|
|
39
|
+
Boolean isInternal,
|
|
40
|
+
Long videoId
|
|
41
|
+
) {
|
|
42
|
+
FullscreenExoPlayerFragment fsFragment = new FullscreenExoPlayerFragment();
|
|
43
|
+
|
|
44
|
+
fsFragment.videoPath = videoPath;
|
|
45
|
+
fsFragment.videoRate = videoRate;
|
|
46
|
+
fsFragment.exitOnEnd = exitOnEnd;
|
|
47
|
+
fsFragment.loopOnEnd = loopOnEnd;
|
|
48
|
+
fsFragment.pipEnabled = pipEnabled;
|
|
49
|
+
fsFragment.bkModeEnabled = bkModeEnabled;
|
|
50
|
+
fsFragment.showControls = showControls;
|
|
51
|
+
fsFragment.displayMode = displayMode;
|
|
52
|
+
fsFragment.subTitle = subTitle;
|
|
53
|
+
fsFragment.language = language;
|
|
54
|
+
fsFragment.subTitleOptions = subTitleOptions;
|
|
55
|
+
fsFragment.headers = headers;
|
|
56
|
+
fsFragment.title = title;
|
|
57
|
+
fsFragment.smallTitle = smallTitle;
|
|
58
|
+
fsFragment.accentColor = accentColor;
|
|
59
|
+
fsFragment.chromecast = chromecast;
|
|
60
|
+
fsFragment.artwork = artwork;
|
|
61
|
+
fsFragment.isTV = isTV;
|
|
62
|
+
fsFragment.playerId = playerId;
|
|
63
|
+
fsFragment.isInternal = isInternal;
|
|
64
|
+
fsFragment.videoId = videoId;
|
|
65
|
+
return fsFragment;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public PickerVideoFragment createPickerVideoFragment() {
|
|
69
|
+
return new PickerVideoFragment();
|
|
70
|
+
}
|
|
71
|
+
}
|