i am using Vitamio SDK in my app to play live streams. It does play but it like being in slow motion, first thought was, slow internet connection.. increased buffer size, and changed video quality to low.
But still does the same. Can Anybody help me?
here is my code:
package com.example.asd;
import android.graphics.PixelFormat;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.View;
import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import io.vov.vitamio.LibsChecker;
import io.vov.vitamio.MediaPlayer;
import io.vov.vitamio.MediaPlayer.OnBufferingUpdateListener;
import io.vov.vitamio.MediaPlayer.OnInfoListener;
import io.vov.vitamio.utils.StringUtils;
import io.vov.vitamio.widget.MediaController;
import io.vov.vitamio.widget.VideoView;
public class VideoBuffer extends AppCompatActivity implements OnInfoListener, OnBufferingUpdateListener {
private String path = "rtmp://stream.smcloud.net/live2/eska_party/eska_party_360p";
private VideoView mVideoView;
private ProgressBar pb;
private TextView downloadRateView;
private TextView loadRateView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (!LibsChecker.checkVitamioLibs(this))
return;
setContentView(R.layout.activity_video_buffer);
mVideoView = (VideoView) findViewById(R.id.buffer);
pb = (ProgressBar) findViewById(R.id.probar);
downloadRateView = (TextView) findViewById(R.id.download_rate);
loadRateView = (TextView) findViewById(R.id.load_rate);
if (path == "") {
// Tell the user to provide a media file URL/path.
Toast.makeText(
VideoBuffer.this,
"Please edit VideoBuffer 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));
*/
/*uridec = Uri.parse(path);*/
/*mVideoView.setVideoURI(uri);*/
mVideoView.setVideoURI(Uri.parse(path));
//mVideoView.setVideoURI(path);
mVideoView.setMediaController(new MediaController(this));
mVideoView.setOnInfoListener(this);
mVideoView.setOnBufferingUpdateListener(this);
mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mediaPlayer) {
// optional need Vitamio 4.0
mediaPlayer.setPlaybackSpeed(1.0f);
mediaPlayer.setBufferSize(1024 * 10);
mediaPlayer.setVideoQuality(MediaPlayer.VIDEOQUALITY_LOW);
mVideoView.requestFocus();
}
});
}
}
@Override
public boolean onInfo(MediaPlayer mp, int what, int extra) {
switch (what) {
case MediaPlayer.MEDIA_INFO_BUFFERING_START:
if (mVideoView.isPlaying()) {
mVideoView.pause();
pb.setVisibility(View.VISIBLE);
downloadRateView.setText("DR" + extra + "kb/s" + " ");
Log.e("PRIVPLAYERLOGS", "buff update " + extra + "kb/s");
loadRateView.setText("LR" + extra + "kb/s" + " ");
downloadRateView.setVisibility(View.VISIBLE);
loadRateView.setVisibility(View.VISIBLE);
}
break;
case MediaPlayer.MEDIA_INFO_BUFFERING_END:
mVideoView.start();
pb.setVisibility(View.GONE);
downloadRateView.setVisibility(View.GONE);
loadRateView.setVisibility(View.GONE);
break;
case MediaPlayer.MEDIA_INFO_DOWNLOAD_RATE_CHANGED:
downloadRateView.setText("" + extra + "kb/s" + " ");
Log.e("PRIVPLAYERLOGS", "buff update " + extra + "kb/s");
break;
}
return true;
}
@Override
public void onBufferingUpdate(MediaPlayer mp, int percent) {
loadRateView.setText(percent + "%");
Log.e("PRIVPLAYERLOGS", "buff update "+ percent + "%");
}
}
If you experienced "LAGGING" problem, that is caused by Android Emulator.
I am using 2GB of memory in Emulator Settings and for some reason Vitamio has some problems in Android Emulator by playing video.
Try do it on real device and this issue will or should be gone.