Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Support For Loading Video Dialog #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@ Android video stream rotation
=============================

:author: Grzegorz Adam Hankiewicz <[email protected]>
:edited: Aman Virk <http://www.thetutlage.com>

=============================
Added Support For Loading Video Dialog
=============================

Since Adam did the nice job by setting up an video player which takes care of screen orientation , i thought of adding
support of loading video dialog which shows the user a dialog saying "Loading video" instead of a blank screen.

What's Changed
==============

Changes are only inside "HelloInterruptVideoStream.java" file.
=======


.. contents::

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.elhaso.tutinterruptvideostream;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.res.Configuration;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnPreparedListener;
import android.media.MediaPlayer.OnVideoSizeChangedListener;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.Display;
Expand All @@ -23,30 +25,35 @@ public class HelloInterruptVideoStream extends Activity
private int screen_width, screen_height;
private int media_width, media_height;
private boolean landscape;

ProgressDialog progressDialog;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

setOnLoadVideo();
}

public void setOnLoadVideo(){
getWindow().clearFlags(WindowManager
.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);

// Get the size of the device, will be our maximum.
progressDialog = ProgressDialog.show(HelloInterruptVideoStream.this, "Loading","Loading video .... ", true);
Display display = getWindowManager().getDefaultDisplay();
screen_width = display.getWidth();
screen_height = display.getHeight();

video_view = (VideoViewCustom)findViewById(R.id.surface_view);
video_view.setOnPreparedListener(this);
video_view.setOnPreparedListener(HelloInterruptVideoStream.this);
resize();

video_view.setVideoURI(Uri.parse(path));
video_view.setMediaController(new MediaController(this));
video_view.setMediaController(new MediaController(HelloInterruptVideoStream.this));
video_view.requestFocus();
}

Expand All @@ -59,7 +66,6 @@ public void onCreate(Bundle savedInstanceState)
public void onConfigurationChanged(Configuration newConfig)
{
super.onConfigurationChanged(newConfig);

landscape =
(Configuration.ORIENTATION_LANDSCAPE == newConfig.orientation);
resize();
Expand Down Expand Up @@ -119,6 +125,7 @@ public void onPrepared(MediaPlayer mp)
// Yuck, no sizes yet? Register a callback.
mp.setOnVideoSizeChangedListener(this);
}
progressDialog.dismiss();
}

/** Called when the media player knows the video size.
Expand Down