shakebug-react-native 2.4.8 → 2.4.10
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/README.md +0 -12
- package/VideoPlayer/PlayVideo.tsx +4 -46
- package/VideoPlayer/index.js +6 -43
- package/android/src/main/java/com/shakebug/BaseUtils.java +7 -19
- package/android/src/main/java/com/shakebug/DeviceUtil.java +34 -21
- package/android/src/main/java/com/shakebug/DrawingView.java +8 -3
- package/android/src/main/java/com/shakebug/RecordScreenModule.java +1 -2
- package/android/src/main/java/com/shakebug/ShakebugPackage.java +3 -3
- package/android/src/main/java/com/shakebug/UnitConverter.java +8 -8
- package/android/src/main/java/com/shakebug/VideoPlayerModule.java +81 -0
- package/android/src/main/java/com/shakebug/VideoTrimModule.java +387 -0
- package/android/src/main/java/com/shakebug/VideoTrimUtil.java +133 -0
- package/android/src/main/java/com/shakebug/ViewShot.java +5 -2
- package/android/src/main/java/com/shakebug/adapters/VideoTrimmerAdapter.java +53 -0
- package/android/src/main/java/com/shakebug/callback/SingleCallback.java +0 -6
- package/android/src/main/java/com/shakebug/thread/BackgroundExecutor.java +1 -93
- package/android/src/main/java/com/shakebug/thread/UiThreadExecutor.java +0 -37
- package/android/src/main/java/com/shakebug/utils/StorageUtil.java +135 -0
- package/android/src/main/java/com/shakebug/utils/VideoTrimmerUtil.java +70 -0
- package/android/src/main/java/com/shakebug/widgets/RangeSeekBarView.java +534 -0
- package/android/src/main/java/com/shakebug/widgets/SpacesItemDecoration2.java +1 -2
- package/android/src/main/java/com/shakebug/widgets/VideoPlayerView.java +317 -0
- package/android/src/main/java/com/shakebug/widgets/VideoTrimmerView.java +520 -0
- package/android/src/main/res/drawable/ic_volume_off.xml +10 -0
- package/android/src/main/res/drawable/ic_volume_on.xml +10 -0
- package/android/src/main/res/layout/{video_player_view.xml → shakebug_video_player_view.xml} +29 -9
- package/ios/TrimVideo/ShakebugSDKVideoTrim.swift +389 -0
- package/ios/TrimVideo/VideoTrim-Bridging-Header.h +10 -0
- package/ios/TrimVideo/VideoTrim.m +23 -0
- package/ios/TrimVideo/VideoTrimmer.swift +810 -0
- package/ios/TrimVideo/VideoTrimmerThumb.swift +119 -0
- package/ios/TrimVideo/VideoTrimmerViewController.swift +322 -0
- package/ios/VideoPlayer/VideoPlayerModule.m +23 -7
- package/package.json +1 -1
- package/src/APIs/AddIssue.js +11 -1
- package/src/Componanats/CustomAlert.js +2 -6
- package/src/Componanats/ErrorHandler.js +10 -1
- package/src/Componanats/LoadingModal.js +59 -0
- package/src/Componanats/ShakeFunction.js +2 -10
- package/src/Screens/AddDetailsScreen.js +29 -33
- package/src/Screens/FirstScreen.js +15 -19
- package/src/Screens/Shakebug.js +18 -26
- package/src/Screens/TrimVideoScreen.js +37 -22
- package/src/index.tsx +4 -4
- package/trimVideo/src/index.tsx +12 -48
- /package/android/src/main/res/layout/{video_thumb_item_layout.xml → shakebug_video_thumb_item_layout.xml} +0 -0
- /package/android/src/main/res/layout/{video_trimmer_view.xml → shakebug_video_trimmer_view.xml} +0 -0
package/README.md
CHANGED
|
@@ -23,18 +23,6 @@ Or if you prefer to use Yarn instead of npm:
|
|
|
23
23
|
yarn add shakebug-react-native
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
Make sure to install Required Libraries also
|
|
27
|
-
|
|
28
|
-
```bash
|
|
29
|
-
npm i react-native-video react-native-video-trim@3.0.9
|
|
30
|
-
```
|
|
31
|
-
Or if you prefer to use Yarn instead of npm:
|
|
32
|
-
|
|
33
|
-
```bash
|
|
34
|
-
yarn add react-native-video react-native-video-trim@3.0.9
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
|
|
38
26
|
### iOS
|
|
39
27
|
|
|
40
28
|
1. You need to provide permissions inside `ios/YourProjectName/info.plist`:
|
|
@@ -1,51 +1,9 @@
|
|
|
1
|
-
// videoUtils.js
|
|
2
|
-
|
|
3
|
-
import { Platform } from 'react-native';
|
|
4
1
|
import { NativeModules } from 'react-native';
|
|
5
|
-
const { ShakebugSDKVideoPlayerModule } = NativeModules;
|
|
6
2
|
|
|
7
|
-
|
|
8
|
-
saveToPhoto?: boolean;
|
|
9
|
-
removeAfterSavedToPhoto?: boolean;
|
|
10
|
-
maxDuration?: number;
|
|
11
|
-
cancelButtonText?: string;
|
|
12
|
-
saveButtonText?: string;
|
|
13
|
-
enableCancelDialog?: boolean;
|
|
14
|
-
cancelDialogTitle?: string;
|
|
15
|
-
cancelDialogMessage?: string;
|
|
16
|
-
cancelDialogCancelText?: string;
|
|
17
|
-
cancelDialogConfirmText?: string;
|
|
18
|
-
enableSaveDialog?: boolean;
|
|
19
|
-
saveDialogTitle?: string;
|
|
20
|
-
saveDialogMessage?: string;
|
|
21
|
-
saveDialogCancelText?: string;
|
|
22
|
-
saveDialogConfirmText?: string;
|
|
23
|
-
trimmingText?: string;
|
|
24
|
-
}
|
|
3
|
+
const VideoPlayerModule = NativeModules.ShakebugSDKVideoPlayerModule || NativeModules.ShakebugSDKVideoPlayer;
|
|
25
4
|
|
|
26
5
|
export const PlayVideo = (videoUri: string) => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
removeAfterSavedToPhoto: false,
|
|
31
|
-
maxDuration: 120,
|
|
32
|
-
cancelButtonText: "Cancel",
|
|
33
|
-
saveButtonText: "Save",
|
|
34
|
-
enableCancelDialog: false,
|
|
35
|
-
cancelDialogTitle: "Cancel Editing",
|
|
36
|
-
cancelDialogMessage: "Are you sure you want to cancel editing?",
|
|
37
|
-
cancelDialogCancelText: "No",
|
|
38
|
-
cancelDialogConfirmText: "Yes",
|
|
39
|
-
enableSaveDialog: false,
|
|
40
|
-
saveDialogTitle: "Save Video",
|
|
41
|
-
saveDialogMessage: "Do you want to save this video?",
|
|
42
|
-
saveDialogCancelText: "No",
|
|
43
|
-
saveDialogConfirmText: "Yes",
|
|
44
|
-
trimmingText: "Trimming Video"
|
|
45
|
-
};
|
|
46
|
-
if(Platform.OS == 'android')
|
|
47
|
-
ShakebugSDKVideoPlayerModule.showEditor(videoUri, config);
|
|
48
|
-
else
|
|
49
|
-
ShakebugSDKVideoPlayerModule.playVideo(videoUri);
|
|
6
|
+
if (VideoPlayerModule && VideoPlayerModule.playVideo) {
|
|
7
|
+
VideoPlayerModule.playVideo(videoUri);
|
|
8
|
+
}
|
|
50
9
|
};
|
|
51
|
-
|
package/VideoPlayer/index.js
CHANGED
|
@@ -1,38 +1,13 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import {
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Image, TouchableOpacity, ImageBackground } from 'react-native';
|
|
3
3
|
import { PlayVideo } from './PlayVideo';
|
|
4
|
-
import Video from 'react-native-video';
|
|
5
4
|
|
|
6
5
|
const VideoPlayer = ({ videoUri, img, goToScreenAtIndex, UpdateStatusBar }) => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
// const subscription = eventEmitter.addListener('ShakebugSDKVideoPlayer', (event) => {
|
|
11
|
-
// switch (event.name) {
|
|
12
|
-
// case 'onCancelPlayer': {
|
|
13
|
-
// UpdateStatusBar()
|
|
14
|
-
// goToScreenAtIndex(3)
|
|
15
|
-
// break;
|
|
16
|
-
// }
|
|
17
|
-
// default:
|
|
18
|
-
// break;
|
|
19
|
-
// }
|
|
20
|
-
// });
|
|
21
|
-
|
|
22
|
-
// return () => {
|
|
23
|
-
// subscription.remove();
|
|
24
|
-
// };
|
|
25
|
-
// }
|
|
26
|
-
// }, []);
|
|
27
|
-
|
|
28
|
-
const [isPlayVideo, setIsPlayVideo] = useState(false);
|
|
29
|
-
|
|
30
|
-
const playVideo = () => {
|
|
31
|
-
setIsPlayVideo(true)
|
|
32
|
-
}
|
|
6
|
+
const handlePlayVideo = () => {
|
|
7
|
+
PlayVideo(videoUri);
|
|
8
|
+
};
|
|
33
9
|
|
|
34
10
|
return (
|
|
35
|
-
!isPlayVideo ? (
|
|
36
11
|
<ImageBackground
|
|
37
12
|
source={{ uri: img }}
|
|
38
13
|
style={{
|
|
@@ -51,9 +26,8 @@ const VideoPlayer = ({ videoUri, img, goToScreenAtIndex, UpdateStatusBar }) => {
|
|
|
51
26
|
paddingVertical: 8,
|
|
52
27
|
paddingHorizontal: 15,
|
|
53
28
|
alignItems: 'center',
|
|
54
|
-
|
|
55
29
|
}}
|
|
56
|
-
onPress={
|
|
30
|
+
onPress={handlePlayVideo}
|
|
57
31
|
>
|
|
58
32
|
<Image
|
|
59
33
|
source={require('../src/Assets/images/play.png')}
|
|
@@ -66,17 +40,6 @@ const VideoPlayer = ({ videoUri, img, goToScreenAtIndex, UpdateStatusBar }) => {
|
|
|
66
40
|
/>
|
|
67
41
|
</TouchableOpacity>
|
|
68
42
|
</ImageBackground>
|
|
69
|
-
)
|
|
70
|
-
: (<Video
|
|
71
|
-
source={{ uri: videoUri }}
|
|
72
|
-
style={{
|
|
73
|
-
width: "90%",
|
|
74
|
-
marginLeft: '5%',
|
|
75
|
-
height: "100%"
|
|
76
|
-
}}
|
|
77
|
-
controls={true}
|
|
78
|
-
fullscreen={Platform.OS == 'ios' && true}
|
|
79
|
-
/>)
|
|
80
43
|
);
|
|
81
44
|
};
|
|
82
45
|
|
|
@@ -1,33 +1,21 @@
|
|
|
1
1
|
package com.shakebug;
|
|
2
2
|
|
|
3
3
|
import android.content.Context;
|
|
4
|
-
|
|
5
4
|
import java.lang.ref.WeakReference;
|
|
6
5
|
|
|
7
|
-
/**
|
|
8
|
-
* Author:J.Chou
|
|
9
|
-
* Date: 2016.07.21 11:45.
|
|
10
|
-
* Email: who_know_me@163.com
|
|
11
|
-
* Describe:
|
|
12
|
-
*/
|
|
13
6
|
public class BaseUtils {
|
|
14
|
-
|
|
15
|
-
private static final String ERROR_INIT = "Initialize BaseUtils with invoke init()";
|
|
16
|
-
|
|
17
7
|
private static WeakReference<Context> mWeakReferenceContext;
|
|
18
8
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
mWeakReferenceContext = new WeakReference<>(ctx);
|
|
24
|
-
//something to do...
|
|
9
|
+
public static void init(Context ctx) {
|
|
10
|
+
if (ctx != null) {
|
|
11
|
+
mWeakReferenceContext = new WeakReference<>(ctx.getApplicationContext());
|
|
12
|
+
}
|
|
25
13
|
}
|
|
26
14
|
|
|
27
15
|
public static Context getContext() {
|
|
28
|
-
if (mWeakReferenceContext
|
|
29
|
-
|
|
16
|
+
if (mWeakReferenceContext != null && mWeakReferenceContext.get() != null) {
|
|
17
|
+
return mWeakReferenceContext.get();
|
|
30
18
|
}
|
|
31
|
-
return
|
|
19
|
+
return null;
|
|
32
20
|
}
|
|
33
21
|
}
|
|
@@ -3,44 +3,57 @@ package com.shakebug;
|
|
|
3
3
|
import android.app.ActivityManager;
|
|
4
4
|
import android.content.Context;
|
|
5
5
|
import android.content.pm.PackageManager;
|
|
6
|
-
|
|
6
|
+
import android.content.res.Resources;
|
|
7
7
|
import java.util.List;
|
|
8
8
|
|
|
9
|
-
/**
|
|
10
|
-
* Author:J.Chou
|
|
11
|
-
* Date: 2016.07.19 11:40.
|
|
12
|
-
* Email: who_know_me@163.com
|
|
13
|
-
* Describe:
|
|
14
|
-
*/
|
|
15
9
|
public final class DeviceUtil {
|
|
16
10
|
|
|
17
11
|
public static int getDeviceWidth() {
|
|
18
|
-
|
|
12
|
+
try {
|
|
13
|
+
if (BaseUtils.getContext() != null) {
|
|
14
|
+
return BaseUtils.getContext().getResources().getDisplayMetrics().widthPixels;
|
|
15
|
+
}
|
|
16
|
+
} catch (Exception ignored) {}
|
|
17
|
+
return Resources.getSystem().getDisplayMetrics().widthPixels;
|
|
19
18
|
}
|
|
20
19
|
|
|
21
|
-
public static int getDeviceHeight(){
|
|
22
|
-
|
|
20
|
+
public static int getDeviceHeight() {
|
|
21
|
+
try {
|
|
22
|
+
if (BaseUtils.getContext() != null) {
|
|
23
|
+
return BaseUtils.getContext().getResources().getDisplayMetrics().heightPixels;
|
|
24
|
+
}
|
|
25
|
+
} catch (Exception ignored) {}
|
|
26
|
+
return Resources.getSystem().getDisplayMetrics().heightPixels;
|
|
23
27
|
}
|
|
24
28
|
|
|
25
29
|
public static boolean hasAppInstalled(String pkgName) {
|
|
26
30
|
try {
|
|
27
|
-
BaseUtils.getContext()
|
|
28
|
-
|
|
29
|
-
|
|
31
|
+
if (BaseUtils.getContext() != null) {
|
|
32
|
+
BaseUtils.getContext().getPackageManager().getPackageInfo(pkgName, PackageManager.PERMISSION_GRANTED);
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
} catch (Exception e) {
|
|
30
36
|
return false;
|
|
31
37
|
}
|
|
38
|
+
return false;
|
|
32
39
|
}
|
|
33
40
|
|
|
34
41
|
public static boolean isAppRunInBackground() {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
try {
|
|
43
|
+
if (BaseUtils.getContext() != null) {
|
|
44
|
+
ActivityManager activityManager = (ActivityManager) BaseUtils.getContext().getSystemService(Context.ACTIVITY_SERVICE);
|
|
45
|
+
if (activityManager != null) {
|
|
46
|
+
List<ActivityManager.RunningAppProcessInfo> appProcesses = activityManager.getRunningAppProcesses();
|
|
47
|
+
if (appProcesses != null) {
|
|
48
|
+
for (ActivityManager.RunningAppProcessInfo appProcess : appProcesses) {
|
|
49
|
+
if (appProcess.processName.equals(BaseUtils.getContext().getPackageName())) {
|
|
50
|
+
return appProcess.importance != ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
42
55
|
}
|
|
43
|
-
}
|
|
56
|
+
} catch (Exception ignored) {}
|
|
44
57
|
return false;
|
|
45
58
|
}
|
|
46
59
|
}
|
|
@@ -34,8 +34,13 @@ public class DrawingView extends View {
|
|
|
34
34
|
if (bitmap != null) {
|
|
35
35
|
bitmap.recycle();
|
|
36
36
|
}
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
if (w > 0 && h > 0) {
|
|
38
|
+
bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
|
|
39
|
+
canvas = new Canvas(bitmap);
|
|
40
|
+
} else {
|
|
41
|
+
bitmap = null;
|
|
42
|
+
canvas = null;
|
|
43
|
+
}
|
|
39
44
|
}
|
|
40
45
|
|
|
41
46
|
@Override
|
|
@@ -81,7 +86,7 @@ public class DrawingView extends View {
|
|
|
81
86
|
}
|
|
82
87
|
|
|
83
88
|
public void clearCanvas() {
|
|
84
|
-
if (canvas != null) {
|
|
89
|
+
if (canvas != null && bitmap != null && bitmap.getWidth() > 0 && bitmap.getHeight() > 0) {
|
|
85
90
|
bitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
|
|
86
91
|
canvas = new Canvas(bitmap);
|
|
87
92
|
invalidate();
|
|
@@ -51,6 +51,7 @@ public class RecordScreenModule extends ReactContextBaseJavaModule implements HB
|
|
|
51
51
|
|
|
52
52
|
public RecordScreenModule(ReactApplicationContext reactContext) {
|
|
53
53
|
super(reactContext);
|
|
54
|
+
reactContext.addActivityEventListener(mActivityEventListener);
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
@NonNull
|
|
@@ -90,7 +91,6 @@ public class RecordScreenModule extends ReactContextBaseJavaModule implements HB
|
|
|
90
91
|
|
|
91
92
|
@ReactMethod
|
|
92
93
|
public void setup(ReadableMap readableMap) {
|
|
93
|
-
new Application().onCreate();
|
|
94
94
|
screenWidth = readableMap.hasKey("width") ? (int) Math.ceil(readableMap.getDouble("width")) : 0;
|
|
95
95
|
screenHeight = readableMap.hasKey("height") ? (int) Math.ceil(readableMap.getDouble("height")) : 0;
|
|
96
96
|
mic = readableMap.hasKey("mic") && readableMap.getBoolean("mic");
|
|
@@ -117,7 +117,6 @@ public class RecordScreenModule extends ReactContextBaseJavaModule implements HB
|
|
|
117
117
|
hbRecorder.setVideoEncoder("DEFAULT");
|
|
118
118
|
}
|
|
119
119
|
hbRecorder.isAudioEnabled(mic);
|
|
120
|
-
getReactApplicationContext().addActivityEventListener(mActivityEventListener);
|
|
121
120
|
}
|
|
122
121
|
|
|
123
122
|
private void startRecordingScreen() {
|
|
@@ -20,7 +20,7 @@ import java.util.Map;
|
|
|
20
20
|
public class ShakebugPackage implements ReactPackage {
|
|
21
21
|
|
|
22
22
|
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
|
|
23
|
-
|
|
23
|
+
BaseUtils.init(reactContext);
|
|
24
24
|
return Arrays.<NativeModule>asList(
|
|
25
25
|
new ShakebugSensors(reactContext, "ShakebugSDKRNSensorsGyroscope", Sensor.TYPE_GYROSCOPE),
|
|
26
26
|
new ShakebugSensors(reactContext, "ShakebugSDKRNSensorsAccelerometer", Sensor.TYPE_ACCELEROMETER),
|
|
@@ -38,9 +38,9 @@ public class ShakebugPackage implements ReactPackage {
|
|
|
38
38
|
new RNLocalizeModule(reactContext),
|
|
39
39
|
new SharedPreferencesModule(reactContext),
|
|
40
40
|
new ShakebugSDKRNViewShotModule(reactContext),
|
|
41
|
-
|
|
41
|
+
new VideoPlayerModule(reactContext),
|
|
42
42
|
new CreateThumbnailModule(reactContext),
|
|
43
|
-
|
|
43
|
+
new VideoTrimModule(reactContext),
|
|
44
44
|
new ScreenshotDetectorModule(reactContext)
|
|
45
45
|
);
|
|
46
46
|
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
package com.shakebug;
|
|
2
2
|
|
|
3
|
+
import android.content.res.Resources;
|
|
3
4
|
import android.util.DisplayMetrics;
|
|
4
5
|
|
|
5
|
-
/**
|
|
6
|
-
* Created by choujason on 7/31/16.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
6
|
public class UnitConverter {
|
|
10
7
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
public static DisplayMetrics getDisplayMetrics() {
|
|
9
|
+
try {
|
|
10
|
+
if (BaseUtils.getContext() != null) {
|
|
11
|
+
return BaseUtils.getContext().getResources().getDisplayMetrics();
|
|
12
|
+
}
|
|
13
|
+
} catch (Exception ignored) {}
|
|
14
|
+
return Resources.getSystem().getDisplayMetrics();
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
public static float dpToPx(float dp) {
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
package com.shakebug;
|
|
2
|
+
|
|
3
|
+
import android.app.Activity;
|
|
4
|
+
import android.net.Uri;
|
|
5
|
+
import android.os.Handler;
|
|
6
|
+
import android.os.Looper;
|
|
7
|
+
|
|
8
|
+
import androidx.appcompat.app.AlertDialog;
|
|
9
|
+
|
|
10
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
11
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
12
|
+
import com.facebook.react.bridge.ReactMethod;
|
|
13
|
+
import com.shakebug.interfaces.VideoPlayerListner;
|
|
14
|
+
import com.shakebug.widgets.VideoPlayerView;
|
|
15
|
+
|
|
16
|
+
import java.io.File;
|
|
17
|
+
|
|
18
|
+
public class VideoPlayerModule extends ReactContextBaseJavaModule {
|
|
19
|
+
private final ReactApplicationContext reactContext;
|
|
20
|
+
private AlertDialog alertDialog;
|
|
21
|
+
private VideoPlayerView videoPlayerView;
|
|
22
|
+
|
|
23
|
+
public VideoPlayerModule(ReactApplicationContext reactContext) {
|
|
24
|
+
super(reactContext);
|
|
25
|
+
this.reactContext = reactContext;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@Override
|
|
29
|
+
public String getName() {
|
|
30
|
+
return "ShakebugSDKVideoPlayerModule";
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@ReactMethod
|
|
34
|
+
public void playVideo(final String videoUri) {
|
|
35
|
+
final Activity currentActivity = getCurrentActivity();
|
|
36
|
+
if (currentActivity == null || currentActivity.isFinishing() || videoUri == null || videoUri.isEmpty()) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
new Handler(Looper.getMainLooper()).post(new Runnable() {
|
|
41
|
+
@Override
|
|
42
|
+
public void run() {
|
|
43
|
+
try {
|
|
44
|
+
Activity act = getCurrentActivity();
|
|
45
|
+
if (act == null || act.isFinishing()) return;
|
|
46
|
+
|
|
47
|
+
videoPlayerView = new VideoPlayerView(act);
|
|
48
|
+
videoPlayerView.setOnTrimVideoListener(new VideoPlayerListner() {
|
|
49
|
+
@Override
|
|
50
|
+
public void onCancel() {
|
|
51
|
+
try {
|
|
52
|
+
if (alertDialog != null && alertDialog.isShowing()) {
|
|
53
|
+
alertDialog.dismiss();
|
|
54
|
+
}
|
|
55
|
+
} catch (Exception ignored) {}
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
String cleanPath = videoUri.replace("file://", "");
|
|
60
|
+
Uri uri = cleanPath.startsWith("/") ? Uri.fromFile(new File(cleanPath)) : Uri.parse(videoUri);
|
|
61
|
+
videoPlayerView.initVideoByURI(uri);
|
|
62
|
+
|
|
63
|
+
AlertDialog.Builder builder = new AlertDialog.Builder(act, android.R.style.Theme_Black_NoTitleBar_Fullscreen);
|
|
64
|
+
builder.setCancelable(true);
|
|
65
|
+
alertDialog = builder.create();
|
|
66
|
+
alertDialog.setView(videoPlayerView);
|
|
67
|
+
alertDialog.show();
|
|
68
|
+
|
|
69
|
+
alertDialog.setOnDismissListener(dialog -> {
|
|
70
|
+
if (videoPlayerView != null) {
|
|
71
|
+
videoPlayerView.onDestroy();
|
|
72
|
+
videoPlayerView = null;
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
} catch (Exception e) {
|
|
76
|
+
e.printStackTrace();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|