小白下载 v4.0版本的 MD5 值为:7dece071a9daf7f7f4f87ff1c058a020
以下内容为反编译后的 SuperPlayerView.java 源代码,内容仅作参考
package io.dcloud.uniplugin.player;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.AsyncTask;
import android.util.AttributeSet;
import android.util.Base64;
import android.widget.FrameLayout;
import android.widget.ImageView;
import androidx.core.app.NotificationCompat;
import io.dcloud.uniplugin.SuperPlayer;
import io.dcloud.uniplugin.config.ResourcesConfig;
import io.dcloud.uniplugin.controller.StandardVideoController;
import io.dcloud.uniplugin.player.VideoView;
import io.dcloud.uniplugin.view.CompleteView;
import io.dcloud.uniplugin.view.ErrorView;
import io.dcloud.uniplugin.view.GestureView;
import io.dcloud.uniplugin.view.LiveControlView;
import io.dcloud.uniplugin.view.PrepareView;
import io.dcloud.uniplugin.view.TitleView;
import io.dcloud.uniplugin.view.VodControlView;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.ProtocolException;
import java.net.URL;
import java.util.HashMap;
import org.cybergarage.http.HTTP;
public class SuperPlayerView extends FrameLayout {
private ResourcesConfig config;
private GestureView gestureView;
private LiveControlView liveControlView;
private VideoView.OnStateChangeListener mOnStateChangeListener;
private PrepareView prepareView;
private SuperPlayer superPlayer;
private ImageView thumbView;
private TitleView titleView;
private StandardVideoController videoController;
private VideoView videoView;
private VodControlView vodControlView;
public SuperPlayerView(Context context) {
super(context);
this.mOnStateChangeListener = new VideoView.SimpleOnStateChangeListener() {
@Override
public void onPlayStateChanged(int i) {
if (i == 3 && SuperPlayerView.this.config.isHideControl && !SuperPlayerView.this.config.isLive) {
SuperPlayerView.this.videoController.startProgress();
}
HashMap hashMap = new HashMap();
hashMap.put("data", Integer.valueOf(i));
SuperPlayerView.this.superPlayer.sendComponentEvent("playStateChange", hashMap);
}
};
}
public SuperPlayerView(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
this.mOnStateChangeListener = new VideoView.SimpleOnStateChangeListener() {
@Override
public void onPlayStateChanged(int i) {
if (i == 3 && SuperPlayerView.this.config.isHideControl && !SuperPlayerView.this.config.isLive) {
SuperPlayerView.this.videoController.startProgress();
}
HashMap hashMap = new HashMap();
hashMap.put("data", Integer.valueOf(i));
SuperPlayerView.this.superPlayer.sendComponentEvent("playStateChange", hashMap);
}
};
}
public void init(ResourcesConfig resourcesConfig, SuperPlayer superPlayer) {
this.config = resourcesConfig;
this.superPlayer = superPlayer;
new InitTask().execute(new Void[0]);
}
public class InitTask extends AsyncTask<Void, Void, Void> {
@Override
public Void doInBackground(Void... voidArr) {
return null;
}
public InitTask() {
}
@Override
public void onPostExecute(Void r1) {
SuperPlayerView.this.initView();
}
}
public void initView() {
StandardVideoController standardVideoController = new StandardVideoController(getContext());
this.videoController = standardVideoController;
standardVideoController.setEnableOrientation(this.config.autoOrientation);
this.prepareView = new PrepareView(getContext(), this.superPlayer);
if (this.config.thumbUrl != null && !this.config.thumbUrl.equals("")) {
this.thumbView = (ImageView) this.prepareView.findViewById(ResourcesConfig.getThumbView());
if (this.config.thumbUrl.startsWith("data:image/jpeg;base64") || this.config.thumbUrl.startsWith("data:image/png;base64") || this.config.thumbUrl.startsWith("data:image/jpg;base64")) {
byte[] decode = Base64.decode(this.config.thumbUrl.split(",")[1], 0);
this.thumbView.setImageBitmap(BitmapFactory.decodeByteArray(decode, 0, decode.length));
} else {
new Thread(new Runnable() {
@Override
public void run() {
try {
HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(SuperPlayerView.this.config.thumbUrl).openConnection();
httpURLConnection.setRequestMethod(HTTP.GET);
httpURLConnection.setConnectTimeout(5000);
if (httpURLConnection.getResponseCode() == 200) {
InputStream inputStream = httpURLConnection.getInputStream();
final Bitmap decodeStream = BitmapFactory.decodeStream(inputStream);
SuperPlayerView.this.thumbView.post(new Runnable() {
@Override
public void run() {
SuperPlayerView.this.thumbView.setImageBitmap(decodeStream);
}
});
inputStream.close();
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (ProtocolException e2) {
e2.printStackTrace();
} catch (IOException e3) {
e3.printStackTrace();
}
}
}).start();
}
}
this.prepareView.setClickStart();
this.videoController.addControlComponent(this.prepareView);
this.videoController.addControlComponent(new CompleteView(getContext()));
this.videoController.addControlComponent(new ErrorView(getContext()));
GestureView gestureView = new GestureView(getContext());
this.gestureView = gestureView;
this.videoController.addControlComponent(gestureView);
if (!this.config.isHideControl) {
if (this.config.isLive) {
LiveControlView liveControlView = new LiveControlView(getContext(), this.superPlayer);
this.liveControlView = liveControlView;
this.videoController.addControlComponent(liveControlView);
} else {
VodControlView vodControlView = new VodControlView(getContext(), this.superPlayer);
this.vodControlView = vodControlView;
this.videoController.addControlComponent(vodControlView);
}
TitleView titleView = new TitleView(getContext(), this.superPlayer);
this.titleView = titleView;
titleView.setTitle(this.config.title);
this.videoController.addControlComponent(this.titleView);
}
this.videoController.setCanChangePosition(true ^ this.config.isLive);
this.videoController.setSuperPlayer(this.superPlayer);
VideoView videoView = (VideoView) findViewById(ResourcesConfig.getVideoPlayer());
this.videoView = videoView;
videoView.setSuperPlayer(this.superPlayer);
this.videoView.setVideoController(this.videoController);
this.videoView.setUrl(this.config.url, this.config.headers);
this.videoView.setLooping(this.config.isLooping);
this.videoView.addOnStateChangeListener(this.mOnStateChangeListener);
this.videoView.setScreenScaleType(0);
if (this.config.autoPlay) {
this.videoView.start();
}
}
public void releaseVideo() {
this.videoView.release();
}
public void playVideo() {
this.videoView.start();
}
public void pauseVideo() {
this.videoView.pause();
}
public void rePlay(boolean z) {
this.videoView.replay(z);
}
public void toggleFullScreen(boolean z) {
if (this.prepareView.getView().getVisibility() == 0) {
HashMap hashMap = new HashMap();
hashMap.put(NotificationCompat.CATEGORY_MESSAGE, "prepareView is not close!!!");
this.superPlayer.sendComponentEvent("fullScreenChange", hashMap);
return;
}
this.videoController.toggleFullScreen(z);
}
public void seekTo(Long l) {
this.videoView.seekTo(l.longValue());
}
public void setUrl(String str) {
this.videoView.setUrl(str, this.config.headers);
}
public void setTitle(String str) {
this.titleView.setTitle(str);
}
public void changeControl(boolean z) {
if (this.config.isLive != z) {
if (this.config.isLive) {
this.config.setLive(false);
this.videoController.startProgress();
if (this.config.isHideControl) {
return;
}
this.videoController.removeControlComponent(this.liveControlView);
VodControlView vodControlView = new VodControlView(getContext(), this.superPlayer);
this.vodControlView = vodControlView;
this.videoController.addControlComponent(vodControlView);
return;
}
this.config.setLive(true);
this.videoController.stopProgress();
if (this.config.isHideControl) {
return;
}
this.videoController.removeControlComponent(this.vodControlView);
LiveControlView liveControlView = new LiveControlView(getContext(), this.superPlayer);
this.liveControlView = liveControlView;
this.videoController.addControlComponent(liveControlView);
}
}
}