package com.fanxin.huangfangyi.main.ulive.play;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Toast;
import com.fanxin.huangfangyi.R;
import com.fanxin.huangfangyi.main.ulive.preference.Settings;
import com.ucloud.player.widget.v2.UVideoView;
public class VideoActivity extends AppCompatActivity implements UVideoView.Callback {
private static final String TAG = "VideoActivity";
private UVideoView mVideoView;
String rtmpPlayStreamUrl = "rtmp://vlive3.rtmp.cdn.ucloud.com.cn/ucloud/";
Settings mSettings;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.live_activity_play);
mVideoView = (UVideoView) findViewById(R.id.videoview);
mSettings = new Settings(this);
mVideoView.setPlayType(UVideoView.PlayType.LIVE);
mVideoView.setPlayMode(UVideoView.PlayMode.NORMAL);
mVideoView.setRatio(UVideoView.VIDEO_RATIO_FILL_PARENT);
mVideoView.setDecoder(UVideoView.DECODER_VOD_SW);
mVideoView.registerCallback(this);
mVideoView.setVideoPath(rtmpPlayStreamUrl + mSettings.getPusblishStreamId());
// mVideoView.setVideoPath(rtmpPlayStreamUrl);
}
@Override
protected void onDestroy() {
super.onDestroy();
if (mVideoView != null) {
mVideoView.setVolume(0,0);
mVideoView.stopPlayback();
mVideoView.release(true);
}
}
@Override
public void onEvent(int what, String message) {
Log.d(TAG, "what:" + what + ", message:" + message);
switch (what) {
case UVideoView.Callback.EVENT_PLAY_START:
break;
case UVideoView.Callback.EVENT_PLAY_PAUSE:
break;
case UVideoView.Callback.EVENT_PLAY_STOP:
break;
case UVideoView.Callback.EVENT_PLAY_COMPLETION:
break;
case UVideoView.Callback.EVENT_PLAY_DESTORY:
break;
case UVideoView.Callback.EVENT_PLAY_ERROR:
Toast.makeText(this, "message:" + message, Toast.LENGTH_SHORT).show();
break;
case UVideoView.Callback.EVENT_PLAY_RESUME:
break;
case UVideoView.Callback.EVENT_PLAY_INFO_BUFFERING_START:
// Toast.makeText(VideoActivity.this, "unstable network", Toast.LENGTH_SHORT).show();
break;
}
}
public void close(View view) {
finish();
}
}