影视仓 v5.0.24版本的 MD5 值为:620341689ccdc375a3b86527e140060e
以下内容为反编译后的 IjkDemoActivity.java 源代码,内容仅作参考
package tv.danmaku.ijk.media.player.demo;
import android.app.Activity;
import android.graphics.SurfaceTexture;
import android.os.Bundle;
import android.util.Log;
import android.view.Surface;
import android.view.TextureView;
import android.view.View;
import com.github.tvbox.osc.player.R$id;
import com.github.tvbox.osc.player.R$layout;
import tv.danmaku.ijk.media.player.IMediaPlayer;
import tv.danmaku.ijk.media.player.IjkMediaPlayer;
public class IjkDemoActivity extends Activity {
private static final String TAG = "IjkDemoActivity";
private IjkMediaPlayer ijkMediaPlayer;
private Surface surface;
private TextureView texture_view;
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
getWindow().addFlags(128);
setContentView(R$layout.ijk_demo_activity);
findViewById(R$id.button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
IjkDemoActivity.this.startPlay(view);
}
});
TextureView textureView = (TextureView) findViewById(R$id.texture_view);
this.texture_view = textureView;
textureView.setSurfaceTextureListener(new TextureView.SurfaceTextureListener() {
@Override
public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int i, int i2) {
IjkDemoActivity.this.surface = new Surface(surfaceTexture);
}
@Override
public boolean onSurfaceTextureDestroyed(SurfaceTexture surfaceTexture) {
return false;
}
@Override
public void onSurfaceTextureSizeChanged(SurfaceTexture surfaceTexture, int i, int i2) {
}
@Override
public void onSurfaceTextureUpdated(SurfaceTexture surfaceTexture) {
}
});
}
@Override
public void onDestroy() {
super.onDestroy();
IjkMediaPlayer ijkMediaPlayer = this.ijkMediaPlayer;
if (ijkMediaPlayer != null) {
ijkMediaPlayer.stop();
this.ijkMediaPlayer.release();
}
}
@Override
public void onPause() {
super.onPause();
IjkMediaPlayer ijkMediaPlayer = this.ijkMediaPlayer;
if (ijkMediaPlayer != null) {
ijkMediaPlayer.pause();
}
}
public void startPlay(View view) {
if (this.surface == null) {
Log.d(TAG, "null == surface");
return;
}
IjkMediaPlayer ijkMediaPlayer = this.ijkMediaPlayer;
if (ijkMediaPlayer == null) {
this.ijkMediaPlayer = new IjkMediaPlayer();
} else {
ijkMediaPlayer.reset();
}
try {
this.ijkMediaPlayer.setOption(1, "timeout", 200L);
this.ijkMediaPlayer.setSurface(this.surface);
this.ijkMediaPlayer.setDataSource("https://cache.tkys.tv/m3u8/dsj/guochan/mp1/1.m3u8");
this.ijkMediaPlayer.setOnPreparedListener(new IMediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(IMediaPlayer iMediaPlayer) {
iMediaPlayer.start();
}
});
this.ijkMediaPlayer.prepareAsync();
} catch (Exception e) {
e.printStackTrace();
}
}
}