public class MainActivity extends AppCompatActivity {
AliVcMediaPlayer mPlayer;
SurfaceView mSurfaceView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mSurfaceView = findViewById(R.id.surface_view);
mSurfaceView.getHolder().addCallback(mCallback);
mPlayer = new AliVcMediaPlayer(this, mSurfaceView);
}
SurfaceHolder.Callback mCallback = new SurfaceHolder.Callback() {
@Override
public void surfaceCreated(SurfaceHolder surfaceHolder) {
// mPlayer.prepareAndPlay("http://zbjs.yuge.com/zhibo/record/yixin/10062961-jvoz3f9e/2019-05-15-16-38-29_2019-05-15-16-39-50.mp4");
mPlayer.prepareAndPlay("http://im.yuge.com/im/yx/attachment/video/ma48mnpkqdrqpq22c0med3804.mp4");
}
@Override
public void surfaceChanged(SurfaceHolder surfaceHolder, int i, int i1, int i2) {
}
@Override
public void surfaceDestroyed(SurfaceHolder surfaceHolder) {
}
};
}
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
AliVcMediaPlayer.init(this);
}
}
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.zk.aliplayerdemo"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
allprojects {
repositories {
jcenter()
flatDir {
dirs 'libs'
}
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
compile 'com.aliyun.dpa:oss-android-sdk:+'
}
您好,我看您的代码, 是没有调用setView的方法的。可以调用一下这个方法。或者参考一下demo的设置。
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。