Sunday, 8 September 2013

Andriod HLS(IPTV) VideoStreaming Streaming on Google TV

Andriod HLS(IPTV) VideoStreaming Streaming on Google TV

I'm able to Play HLS(IPTV) Video Streaming on Google TV Successfully,But
the video is playing with some blur and all (I'm getting blur lines in the
bottom of the Screen),Could any one help me how to avoid this?Is there any
Resolution Problem,if so how to avoid?
Here My Code:
public class HLSActivity extends Activity
implements AudioManager.OnAudioFocusChangeListener,
MediaPlayer.OnCompletionListener,
MediaPlayer.OnErrorListener {
public static final String TAG = "VPActivity";
Button button;
public VideoView mVideoView = null;
private LayoutParams mDefaultVideoViewSize;
// Handle AudioFocus issues
@Override
public void onAudioFocusChange(int focusChange) {
switch(focusChange) {
case AudioManager.AUDIOFOCUS_GAIN:
Log.i(TAG, "AF Gain");
if (mVideoView != null)
mVideoView.resume();
break;
case AudioManager.AUDIOFOCUS_LOSS:
Log.i(TAG, "AF Loss");
if (mVideoView != null)
mVideoView.stopPlayback();
mVideoView = null;
this.finish(); // Let's move on.
break;
case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT:
case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK:
Log.i(TAG, "AF Transient");
if (mVideoView != null)
mVideoView.pause();
break;
}
}
@Override
public void onCompletion(MediaPlayer mp) {
Log.i(TAG, "done.");
mVideoView = null;
this.finish();
}
@Override
public boolean onError(MediaPlayer mp, int what, int extra) {
Log.e(TAG, "IO Error e=" + what + " x=" + extra);
return false; // Will call onCompletion
}
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sandbox);
// Request Audio Focus
AudioManager am = (AudioManager)
getSystemService(Context.AUDIO_SERVICE);
int result = am.requestAudioFocus(this, AudioManager.STREAM_MUSIC,
AudioManager.AUDIOFOCUS_GAIN);
if (result != AudioManager.AUDIOFOCUS_REQUEST_GRANTED) {
Log.e(TAG, "Can't get AudioFocus " + result);
this.finish(); // Just give up.
}
mVideoView = (VideoView) findViewById(R.id.videoView);
mVideoView.setVideoPath("http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4");
mVideoView.setOnCompletionListener(this);
mVideoView.setOnErrorListener(this);
MediaController mc = new MediaController(this, true);
mc.setMediaPlayer(mVideoView);
mc.setAnchorView(mVideoView);
mVideoView.setMediaController(mc);
mVideoView.requestFocus();
mVideoView.start();
mDefaultVideoViewSize = mVideoView.getLayoutParams();
}
}
My LayoutXML is:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<VideoView
android:id="@+id/videoView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>

No comments:

Post a Comment