gpt4 book ai didi

使用 Vitamio 库的 Android VideoView 质量在电视盒上非常糟糕

转载 作者:太空宇宙 更新时间:2023-11-03 13:26:08 25 4
gpt4 key购买 nike

通过实现用于实时流媒体的 Vitamio 库,努力为 G-Box 获得更好的质量。

代码中使用了具有 .mp4 视频的示例在线视频 URL。但是当我们在下载后在媒体播放器中播放时效果很好,而当我通过在线流媒体尝试时,质量变得很差。

以下是在videoView上播放视频的代码。

 public class VideoViewDemo extends Activity {

/**
* TODO: Set the path variable to a streaming video URL or a local media file
* path.
*/
private String path = "";
private VideoView mVideoView;
private ProgressDialog progDailog;
ProgressDialog progressDialog=null;

@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
if (!LibsChecker.checkVitamioLibs(this))
return;
setContentView(R.layout.videoview);
mVideoView = (VideoView) findViewById(R.id.surface_view);
path = "http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4";
if (path == "") {

// Tell the user to provide a media file URL/path.
Toast.makeText(VideoViewDemo.this, "Please edit
VideoViewDemo Activity, and set path" +
" variable to your media file URL/path", Toast.LENGTH_LONG).show();
return;
} else {
/*
* Alternatively,for streaming media you can use
* mVideoView.setVideoURI(Uri.parse(URLstring));
*/
mVideoView.setVideoPath(path);
mVideoView.setVideoQuality(MediaPlayer.VIDEOQUALITY_HIGH);
mVideoView.setMediaController(new MediaController(this));
mVideoView.requestFocus();

progDailog = ProgressDialog.show(this, "Please wait ...",
"Retrieving data ...", true);
progDailog.setCancelable(true);


mVideoView.setOnPreparedListener(
new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mediaPlayer) {
// optional need Vitamio 4.0
//mediaPlayer.setPlaybackSpeed(1.0f);
progDailog.dismiss();
}
});

mVideoView.setOnBufferingUpdateListener(
new OnBufferingUpdateListener() {
@Override
public void onBufferingUpdate(MediaPlayer arg0, int arg1) {

}
});
//mediaPlayer.setPlaybackSpeed(1.0f);
}

}
@Override
protected void onPause() {
mVideoView.pause();
super.onPause();
}

@Override
protected void onResume() {
mVideoView.resume();
progDailog.show();
super.onResume();

}
}

你的即时回复对我帮助很大

最佳答案

毫无疑问,Vitamio 是一个非常好的库,涵盖了与视频流相关的所有错误。

很抱歉,我对 Vitamio 支持团队感到非常失望。我在论坛上发布了问题,但没有收到和反馈。最后,我通过对提供的源进行矿工更改找到了我的问题的解决方案。

enter code here@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
if (!LibsChecker.checkVitamioLibs(this))
return;
setContentView(R.layout.mediaplayer_2);
mPreview = (SurfaceView) findViewById(R.id.surface);
holder = mPreview.getHolder();
holder.addCallback(this);
//holder.setFormat(PixelFormat.RGBA_8888);
holder.setFormat(PixelFormat.RGBX_8888);
extras = getIntent().getExtras();
}

private void playVideo(Integer Media) {
doCleanUp();
Log.e(TAG, "Value Received: " + Media);
try {

switch (Media) {
case LOCAL_VIDEO:
/*
* TODO: Set the path variable to a local media file path.
*/
path = "";
path = Environment.getExternalStorageDirectory() + "/big_buck_bunny.mp4";
Log.e(TAG, "PATH = : " + path);
if (path == "") {
// Tell the user to provide a media file URL.
Toast.makeText(MediaPlayerDemo_Video.this, "Please edit MediaPlayerDemo_Video
Activity, " + "and set the path variable to your media file path."
+ " Your media file must be stored on sdcard.", Toast.LENGTH_LONG).show();
return;
}
break;
case STREAM_VIDEO:
/*
* TODO: Set path variable to progressive streamable mp4 or
* 3gpp format URL. Http protocol should be used.
* Mediaplayer can only play "progressive streamable
* contents" which basically means: 1. the movie atom has to
* precede all the media data atoms. 2. The clip has to be
* reasonably interleaved.
*
*/
path = "http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4";
if (path == "") {
// Tell the user to provide a media file URL.
Toast.makeText(MediaPlayerDemo_Video.this, "Please edit MediaPlayerDemo_Video
Activity," + " and set the path variable to your media file URL.",
Toast.LENGTH_LONG).show();
return;
}

break;

}
// Create a new media player and set the listeners

mMediaPlayer = new MediaPlayer(this);
mMediaPlayer.setVideoQuality(MediaPlayer.VIDEOQUALITY_HIGH);
mMediaPlayer.setDataSource(path);
mMediaPlayer.setDisplay(holder);
mMediaPlayer.prepare();
mMediaPlayer.setOnBufferingUpdateListener(this);
mMediaPlayer.setOnCompletionListener(this);
mMediaPlayer.setOnPreparedListener(this);
mMediaPlayer.setOnVideoSizeChangedListener(this);
mMediaPlayer.getMetadata();
setVolumeControlStream
(AudioManager.STREAM_MUSIC);
//mMediaPlayer.setVideoQuality
(io.vov.vitamio.MediaPlayer.VIDEOQUALITY_HIGH);


} catch (Exception e) {
Log.e(TAG, "error: " + e.getMessage(), e);
}
}

示例源中有一个名为“MediaPlayerDemo_Video.java”的文件替换以下行holder.setFormat(PixelFormat.RGBA_8888);

跟随

holder.setFormat(PixelFormat.RGBX_8888);

这将解决整个问题。

关于使用 Vitamio 库的 Android VideoView 质量在电视盒上非常糟糕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19605839/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com