vlc android 进度,【VLC-Android】vlc-android简例

public void handleMessage(Message msg) {

if (msg == null || msg.getData() == null)

return;

switch (msg.getData().getInt("event")) {

case EventHandler.MediaPlayerTimeChanged:

break;

case EventHandler.MediaPlayerPositionChanged:

break;

case EventHandler.MediaPlayerPlaying:

mHandler.removeMessages(HANDLER_BUFFER_END);

mHandler.sendEmptyMessage(HANDLER_BUFFER_END);

break;

case EventHandler.MediaPlayerBuffering:

break;

case EventHandler.MediaPlayerLengthChanged:

break;

case EventHandler.MediaPlayerEndReached:

//播放完成

break;

}

}

};

private Handler mHandler = new Handler() {

@Override

public void handleMessage(Message msg) {

switch (msg.what) {

case HANDLER_BUFFER_START:

showLoading();

break;

case HANDLER_BUFFER_END:

hideLoading();

break;

case HANDLER_SURFACE_SIZE:

changeSurfaceSize();

break;

}

}

};

private void showLoading() {

mLoadingView.setVisibility(View.VISIBLE);

}

private void hideLoading() {

mLoadingView.setVisibility(View.GONE);

}

private void changeSurfaceSize() {

// get screen size

int dw = getWindowManager().getDefaultDisplay().getWidth();

int dh = getWindowManager().getDefaultDisplay().getHeight();

// calculate aspect ratio

double ar = (double) mVideoWidth / (double) mVideoHeight;

// calculate display aspect ratio

double dar = (double) dw / (double) dh;

switch (mCurrentSize) {

case SURFACE_BEST_FIT:

if (dar < ar)

dh = (int) (dw / ar);

else

dw = (int) (dh * ar);

break;

case SURFACE_FIT_HORIZONTAL:

dh = (int) (dw / ar);

break;

case SURFACE_FIT_VERTICAL:

dw = (int) (dh * ar);

break;

case SURFACE_FILL:

break;

case SURFACE_16_9:

ar = 16.0 / 9.0;

if (dar < ar)

dh = (int) (dw / ar);

else

dw = (int) (dh * ar);

break;

case SURFACE_4_3:

ar = 4.0 / 3.0;

if (dar < ar)

dh = (int) (dw / ar);

else

dw = (int) (dh * ar);

break;

case SURFACE_ORIGINAL:

dh = mVideoHeight;

dw = mVideoWidth;

break;

}

mSurfaceHolder.setFixedSize(mVideoWidth, mVideoHeight);

ViewGroup.LayoutParams lp = mSurfaceView.getLayoutParams();

lp.width = dw;

lp.height = dh;

mSurfaceView.setLayoutParams(lp);

mSurfaceView.invalidate();

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值