@picsa/capacitor-video-player 7.1.0 → 7.2.2
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/CapacitorVideoPlayer.podspec +17 -17
- package/LICENSE +21 -21
- package/android/build.gradle +71 -71
- package/android/src/main/AndroidManifest.xml +3 -3
- package/android/src/main/java/com/jeep/plugin/capacitor/capacitorvideoplayer/CapacitorVideoPlayer.java +71 -71
- package/android/src/main/java/com/jeep/plugin/capacitor/capacitorvideoplayer/CapacitorVideoPlayerPlugin.java +1256 -1256
- package/android/src/main/java/com/jeep/plugin/capacitor/capacitorvideoplayer/FullscreenExoPlayerFragment.java +1595 -1595
- package/android/src/main/java/com/jeep/plugin/capacitor/capacitorvideoplayer/Notifications/MyRunnable.java +21 -21
- package/android/src/main/java/com/jeep/plugin/capacitor/capacitorvideoplayer/Notifications/NotificationCenter.java +61 -61
- package/android/src/main/java/com/jeep/plugin/capacitor/capacitorvideoplayer/PickerVideo/AdapterVideoList.java +47 -47
- package/android/src/main/java/com/jeep/plugin/capacitor/capacitorvideoplayer/PickerVideo/ModelVideo.java +49 -49
- package/android/src/main/java/com/jeep/plugin/capacitor/capacitorvideoplayer/PickerVideo/PickerVideoFragment.java +119 -119
- package/android/src/main/java/com/jeep/plugin/capacitor/capacitorvideoplayer/PickerVideo/VideoRecyclerViewHolder.java +65 -65
- package/android/src/main/java/com/jeep/plugin/capacitor/capacitorvideoplayer/Utilities/FilesUtils.java +101 -101
- package/android/src/main/java/com/jeep/plugin/capacitor/capacitorvideoplayer/Utilities/FragmentUtils.java +32 -32
- package/android/src/main/res/drawable/bg_round_rect_white_50.xml +9 -9
- package/android/src/main/res/drawable/bg_rounded_rectangle_white_corner_rounded.xml +10 -10
- package/android/src/main/res/drawable/exo_close_btn.xml +11 -11
- package/android/src/main/res/drawable/gradient_transparent_middle.xml +12 -12
- package/android/src/main/res/drawable/ic_arrow_left.xml +5 -5
- package/android/src/main/res/drawable/ic_baseline_lq.xml +7 -7
- package/android/src/main/res/drawable/ic_exo_icon_fastforward.xml +35 -35
- package/android/src/main/res/drawable/ic_exo_icon_pause.xml +26 -26
- package/android/src/main/res/drawable/ic_exo_icon_play.xml +36 -36
- package/android/src/main/res/drawable/ic_exo_icon_rewind.xml +35 -35
- package/android/src/main/res/drawable/ic_expand.xml +5 -5
- package/android/src/main/res/drawable/ic_fit.xml +5 -5
- package/android/src/main/res/drawable/ic_image_background.xml +12 -12
- package/android/src/main/res/drawable/ic_img_16_9_background.xml +10 -10
- package/android/src/main/res/drawable/ic_img_9_16_background.xml +10 -10
- package/android/src/main/res/drawable/ic_outline_lock.xml +5 -5
- package/android/src/main/res/drawable/ic_outline_lock_open.xml +5 -5
- package/android/src/main/res/drawable/ic_pip_white.xml +5 -5
- package/android/src/main/res/drawable/ic_views.xml +18 -18
- package/android/src/main/res/drawable/ic_zoom.xml +5 -5
- package/android/src/main/res/layout/bridge_layout_main.xml +15 -15
- package/android/src/main/res/layout/exo_playback_control_view.xml +289 -289
- package/android/src/main/res/layout/exoplayer_layout_youtube.xml +361 -361
- package/android/src/main/res/layout/fragment_fs_exoplayer.xml +50 -50
- package/android/src/main/res/layout/fragment_picker_video.xml +21 -21
- package/android/src/main/res/layout/row_video.xml +76 -76
- package/android/src/main/res/values/colors.xml +14 -14
- package/android/src/main/res/values/strings.xml +3 -3
- package/android/src/main/res/values/styles.xml +3 -3
- package/dist/docs.json +14 -14
- package/ios/Plugin/CapacitorVideoPlayer.swift +63 -63
- package/ios/Plugin/CapacitorVideoPlayerPlugin.h +10 -10
- package/ios/Plugin/CapacitorVideoPlayerPlugin.m +22 -22
- package/ios/Plugin/CapacitorVideoPlayerPlugin.swift +631 -631
- package/ios/Plugin/Extensions/CapacitorVideoPlayerPlugin.AVPlayerViewController.swift +59 -59
- package/ios/Plugin/Extensions/CapacitorVideoPlayerPlugin.File.swift +126 -126
- package/ios/Plugin/Extensions/CapacitorVideoPlayerPlugin.Fullscreen.swift +94 -94
- package/ios/Plugin/Extensions/CapacitorVideoPlayerPlugin.Notifications.swift +140 -140
- package/ios/Plugin/Extensions/CapacitorVideoPlayerPlugin.Observers.swift +180 -180
- package/ios/Plugin/Info.plist +24 -24
- package/ios/Plugin/VideoPicker/VideoHelper.swift +127 -127
- package/ios/Plugin/VideoPicker/VideoPickerViewController.swift +144 -144
- package/ios/Plugin/VideoPlayer/Extensions/AVURLAsset.swift +18 -18
- package/ios/Plugin/VideoPlayer/Extensions/AllOrientationAVPlayerController.swift +12 -12
- package/ios/Plugin/VideoPlayer/Extensions/CMTime.swift +23 -23
- package/ios/Plugin/VideoPlayer/Extensions/LandscapeAVPlayerController.swift +12 -12
- package/ios/Plugin/VideoPlayer/Extensions/Notification.Name.swift +18 -18
- package/ios/Plugin/VideoPlayer/Extensions/PortraitAVPlayerController.swift +12 -12
- package/ios/Plugin/VideoPlayer/Extensions/View.swift +54 -54
- package/ios/Plugin/VideoPlayer/FullScreenVideoPlayerView.swift +601 -601
- package/ios/Plugin/VideoPlayer/Models/Video.swift +28 -28
- package/ios/Plugin/VideoPlayer/Models/VideoModel.swift +42 -42
- package/package.json +92 -92
- package/readme.md +196 -190
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
package com.jeep.plugin.capacitor.capacitorvideoplayer.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
|
-
}
|
|
1
|
+
package com.jeep.plugin.capacitor.capacitorvideoplayer.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
|
+
}
|
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
package com.jeep.plugin.capacitor.capacitorvideoplayer.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
|
-
}
|
|
1
|
+
package com.jeep.plugin.capacitor.capacitorvideoplayer.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
|
+
}
|
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
package com.jeep.plugin.capacitor.capacitorvideoplayer.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.jeep.plugin.capacitor.capacitorvideoplayer.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
|
-
}
|
|
1
|
+
package com.jeep.plugin.capacitor.capacitorvideoplayer.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.jeep.plugin.capacitor.capacitorvideoplayer.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
|
+
}
|
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
package com.jeep.plugin.capacitor.capacitorvideoplayer.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
|
-
}
|
|
1
|
+
package com.jeep.plugin.capacitor.capacitorvideoplayer.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
|
+
}
|
|
@@ -1,119 +1,119 @@
|
|
|
1
|
-
package com.jeep.plugin.capacitor.capacitorvideoplayer.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.jeep.plugin.capacitor.capacitorvideoplayer.Notifications.NotificationCenter;
|
|
20
|
-
import com.jeep.plugin.capacitor.capacitorvideoplayer.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 =
|
|
108
|
-
String
|
|
109
|
-
.valueOf(hrs)
|
|
110
|
-
.concat(
|
|
111
|
-
":".concat(String.format(Locale.UK, "%02d", min).concat(":".concat(String.format(Locale.UK, "%02d", sec))))
|
|
112
|
-
);
|
|
113
|
-
}
|
|
114
|
-
Log.v(TAG, "**** video " + id + " " + title + " " + duration_formatted + " ****");
|
|
115
|
-
videosList.add(new ModelVideo(id, data, title, duration_formatted));
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
1
|
+
package com.jeep.plugin.capacitor.capacitorvideoplayer.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.jeep.plugin.capacitor.capacitorvideoplayer.Notifications.NotificationCenter;
|
|
20
|
+
import com.jeep.plugin.capacitor.capacitorvideoplayer.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 =
|
|
108
|
+
String
|
|
109
|
+
.valueOf(hrs)
|
|
110
|
+
.concat(
|
|
111
|
+
":".concat(String.format(Locale.UK, "%02d", min).concat(":".concat(String.format(Locale.UK, "%02d", sec))))
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
Log.v(TAG, "**** video " + id + " " + title + " " + duration_formatted + " ****");
|
|
115
|
+
videosList.add(new ModelVideo(id, data, title, duration_formatted));
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|