OpenMMUtils.java
4.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
package com.gimi.common.cinema.utils;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.text.TextUtils;
import com.gimi.common.cinema.model.Constant;
import com.xgimi.gimicinema.BuildConfig;
import com.xgimi.gimicinema.activity.AdsPreVideoPlayerActivity;
import java.util.ArrayList;
import java.util.List;
/**
* Created by 李攀 on 2015/7/13
*/
public class OpenMMUtils {
public static void openMM(Context context, String videoPath, String subtitlePath) {
//Splash Video Ads? find Ads,no ads play movie;ads exists play
openMM(context, videoPath, null, subtitlePath);
// Intent intent = new Intent(context, AdsPreVideoPlayerActivity.class);
// intent.putExtra(AdsPreVideoPlayerActivity.MOVIE_PLAY_PATH, videoPath);
// context.startActivity(intent);
}
public static void openMMWithAds(Context context, String videoPath, String subtitlePath) {
//Splash Video Ads? find Ads,no ads play movie;ads exists play
// openMM(context, videoPath, null, subtitlePath);
Intent intent = new Intent(context, AdsPreVideoPlayerActivity.class);
intent.putExtra(AdsPreVideoPlayerActivity.MOVIE_PLAY_PATH, videoPath);
context.startActivity(intent);
}
public static void openMM(Context context, String videoPath, ArrayList<String> list, String subtitlePath) {
//Splash Video Ads? find Ads,no ads play movie;ads exists play
openPlayer(context, videoPath, list, 0);
}
public static void openMM(Context context, String videoPath, List<String> list, String subtitlePath, int position) {
//Splash Video Ads? find Ads,no ads play movie;ads exists play
openPlayer(context, videoPath, list, position);
}
private static final String URL_LIST = "badiu-daye-other-wocao-list";
private static String IS_YB_CALL = "yb_called_movie";
private static String YB_LOOK_SUBTITLE_PATH = "yb_subtitle_path";
public static final String BUNDLE_INDEX_KEY = "position";
public static void openPlayer(Context context, String path, int position) {
openPlayer(context, path, null, position);
}
public static void openPlayer(Context context, String path, List<String> list, int position) {
if (context == null) {
return;
}
if (BuildConfig.MACHINE_TYPE.equals("himedia")) {
Intent it = new Intent(Intent.ACTION_VIEW);
it.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Uri uri = Uri.parse(path);
it.setDataAndType(uri, "video/mp4");
context.startActivity(it);
return;
}
try {
if (!TextUtils.isEmpty(path) && path.endsWith("iso")) {
path = new ISOMountUtils(context).getIsoLargeFilePath(path);
}
ArrayList<String> movies = new ArrayList<>();
if (list != null && list.size() > 1) {
for (String s : list) {
if (!TextUtils.isEmpty(s) && s.endsWith("iso")) {
String isoPath = new ISOMountUtils(context).getIsoLargeFilePath(s);
movies.add(isoPath);
} else {
movies.add(s);
}
}
}
Intent intent = new Intent();
// intent.setComponent(new ComponentName("com.xgimi.gimiplayer", "com.xgimi.gimiplayer.activity.VideoPlayerForYbActivity"));
intent.setComponent(new ComponentName("com.xgimi.gimiplayer", "com.xgimi.gimiplayer.activity.VideoPlayerActivity"));
intent.putExtra("video-path", TextUtils.isEmpty(path) ? "" : path);
intent.putExtra(BUNDLE_INDEX_KEY, position);
intent.putExtra(IS_YB_CALL, true);
int index = 0;
if (!TextUtils.isEmpty(path) && list != null) {
for (int i = 0; i < list.size(); i++) {
if (movies.get(i).equals(path)) {//problems with all iso file movie folder
index = i;
intent.putExtra(BUNDLE_INDEX_KEY, index);
intent.putExtra("video-path", "");
break;
}
}
}
intent.putExtra(URL_LIST, movies);
Constant.startAds = true;
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
} catch (Exception e) {
e.printStackTrace();
}
}
}