Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7248191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T22:06:18+00:00 2026-05-28T22:06:18+00:00

I downloaded the googletv-video-player example and picked only the VideoPlayerActivity as i was only

  • 0

I downloaded the googletv-video-player example and picked only the VideoPlayerActivity as i was only interested in how to play streams.

I modified its xml & java files to play the video in full Screen mode.

here is what i have now:

player.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent" android:layout_width="fill_parent" android:padding="10dp">

<VideoView android:id="@+id/videoViewFullScreen"
        android:layout_width="fill_parent" android:layout_height="fill_parent"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:layout_alignParentBottom="true"/>
</RelativeLayout>

player.java

public class player extends Activity implements
    AudioManager.OnAudioFocusChangeListener,
    MediaPlayer.OnCompletionListener, MediaPlayer.OnErrorListener {
public static final String TAG = "VPActivity";

public VideoView mVideoView = null; 

// Handle AudioFocus issues
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;
    }
}

public void onCompletion(MediaPlayer mp) {
    Log.i(TAG, "done.");
    mVideoView = null;
    this.finish();
}

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);

    // 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.
    }

    //added the following to make video large, hide title and keep activity alive
    //---------------------------------------------------------------------------
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);  
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    //----------------------------------------------------------------      

    setContentView(R.layout.player);


    mVideoView = (VideoView) findViewById(R.id.videoViewFullScreen);
    mVideoView.setVideoPath("rtsp://stream-url");
    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();
}
}

Now I am having TWO issues

 One on Motorola Xoom Tablet and
 Second on Google TV

Issue on Tablet (Android version: 4.0.3)
This is a small issue. Tablet begins streaming video properly. It plays the video for 15-20 minutes perfectly. but after some time, the video stops playing. I checked its state by tapping on the screen and i realized that the player was automatically Stopped.!

enter image description here

When i tapped on Play again.. it began playing stream perfectly.
Why does it stop automatically???

Issue on Google TV (Android version: 3.1)

This is a more serious issue. First the google tv was not playing it at all and would give me the following error:

Cannot Play Video
-----------------------------------------
Sorry, this video cannot be played.

Edit: Now this issue has disappeared and video is played….i did nothing.
But y was it behaving in such way??

Now the issue is that Google TV screen only shows the 1/4th part of the video at upper left corner and the remaining video is hidden…. as if the VideoView object is stretched while some other object is on top of it with an open window on upper left corner and it hiding the VideoView

AND the player activity finishes automatically.

The video even plays in emulator & tablet so i cannot paste the error generated by the emulator (as there is no error there) from LogCat.

My Android application is built with Android 3.1 library

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T22:06:19+00:00Added an answer on May 28, 2026 at 10:06 pm

    I tried your code on GoogleTV and it works fine. The only thing I suggest you need to change for streaming url is this line:

     mVideoView.setVideoPath("rtsp://stream-url");
    

    The above is for playing local files, for streaming urls use the following instead:

     mVideoView.setVideoURI(Uri.parse("rtsp://stream-url"));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Downloaded Qt and Qt Creator. In Qt Creator I can run example programs. Created
Downloaded the WCF REST Template from this location. The default response format is XML,
Downloaded and place phundament3 in local machine, ya its working but not when trying
Downloaded Reachability from Apple, using this method to check for an active connection: -(BOOL)isReachable{
I downloaded a project from TouchMyPixel and when I try to run it with
I downloaded latest SharpDX v2.2 and built the samples in the SharpDXSamples.sln When I
I downloaded and edited a code that from internet, basically what I want to
I downloaded the Facebook SDK for Android and I'm using it in my app
I downloaded Mono software (http://xamarin.com/monoforandroid) and the samples from the xamarin website (http://samples.xamarin.com/Android). When
I downloaded WriteableBitmapEx for winrt (win 8 metro). I added a reference to the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.