1

In the following sample code I am using the API demo app to play streaming videos

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;

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.videoview);
    mVideoView = (VideoView) findViewById(R.id.surface_view);

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

    } else {

        /*
         * Alternatively,for streaming media you can use
         * mVideoView.setVideoURI(Uri.parse(URLstring));
         */
        mVideoView.setVideoPath(path);
        mVideoView.setMediaController(new MediaController(this));
        mVideoView.requestFocus();

    }
}

}

But I face the following errors.

1> While playing the video, if there is an incoming call and if the user receives it and disconnects the call, then a black screen is displayed and the video is no longer played again.

2> Similarly if a user rejects an incoming call, a black screen is displayed and the video is no longer played.

3> When a low battery error message is displayed while a video is being played and the user clicks on OK button of the error message, a black screen is displayed and the video is no longer played.

4> When a SMS comes while viewing the streaming video and the user views the SMS and closes it, a black screen is displayed and the video is no longer played.

Kindly provide me the suggestions/sample code to handle these conditions and solve the errors.

zapping
  • 4,118
  • 6
  • 38
  • 56
chiranjib
  • 5,288
  • 8
  • 53
  • 82

1 Answers1

0
if (path == "")

I don't think this works with strings.

rather

path.equals("") // returns true.

Though this may not actually fix your problems...

zapping
  • 4,118
  • 6
  • 38
  • 56
Emile
  • 11,451
  • 5
  • 50
  • 63