通过实施Vitamio库进行实时流式传输,努力为G-Box提供更好的质量.
在代码中使用了具有.mp4视频的示例在线视频URL.但是当我们在下载后在Media Player中播放它时,效果很好,而当我通过在线流进行尝试时,质量会很差.
以下是在视频视图上播放视频的代码.
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;@OverrIDepublic 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); }}@OverrIDeprotected voID onPause() { mVIDeoVIEw.pause(); super.onPause();}@OverrIDeprotected voID onResume() { mVIDeoVIEw.resume(); progDailog.show(); super.onResume();} }
您的即时回应将对我有很大帮助
解决方法:
毫无疑问,Vitamio是一个非常好的图书馆,涵盖了与视频流有关的所有错误.
抱歉地说,但是Vitamio支持团队对我非常失望.我在论坛上发布了问题,但没有收到并反馈.
最后,我只是通过对提供的来源进行矿工更改来找到解决问题的方法.
enter code here@OverrIDepublic 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 Library的电视盒上的Android VideoView质量太差了全部内容,希望文章能够帮你解决使用Vitamio Library的电视盒上的Android VideoView质量太差了所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)