Android Open Source - glvideoplayer-android Main Activity






From Project

Back to project page glvideoplayer-android.

License

The source code is released under:

Apache License

If you think the Android project glvideoplayer-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package net.binzume.android.glvideoplayer;
//from w w w . j a v a  2s .  co  m
import net.binzume.android.glvideoplayer.R;

import android.net.Uri;
import android.opengl.GLSurfaceView;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.annotation.TargetApi;
import android.app.Activity;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.View;

public class MainActivity extends Activity {
  private GLSurfaceView glview;
  private GLVideoRenderer renderer;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    
    getActionBar().hide();

    glview = (GLSurfaceView) findViewById(R.id.glview);
    glview.setEGLContextClientVersion(2);
    
    renderer = new GLVideoRenderer(this);
    
    if (getIntent().getData() != null) {
      renderer.setVideoUri(getIntent().getData());
    } else {
      String path = Environment.getExternalStorageDirectory() + "/Android/data/net.binzume.android.nicoplayer/sm9.mp4";
      renderer.setVideoUri(Uri.parse("file://"+path));
    }
    
    glview.setRenderer(renderer);
    
    glview.postDelayed(new Runnable() {
      
      @Override
      public void run() {
        if (renderer.commentTexture != null) {
          renderer.commentTexture.draw();
        }
        glview.postDelayed(this, 100);
      }
    }, 100);
  }
  

  @TargetApi(Build.VERSION_CODES.KITKAT)
  @Override
  protected void onStart() {
    super.onStart();
    glview.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
    glview.setKeepScreenOn(true);
  }

  @Override
  protected void onStop() {
    
    // renderer.destroy();

    super.onStop();
  }

  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
  }


  @TargetApi(Build.VERSION_CODES.KITKAT)
  @Override
  public boolean onKeyDown(int keyCode, KeyEvent event) {
    switch(keyCode) {
    case KeyEvent.KEYCODE_DPAD_UP:
    case KeyEvent.KEYCODE_DPAD_DOWN:
      break;
    case KeyEvent.KEYCODE_DPAD_LEFT:
      if (renderer != null && renderer.videoTexture != null) {
        int pos = ((MediaPlayerPlane)renderer.videoTexture).mediaPlayer.getCurrentPosition();
        ((MediaPlayerPlane)renderer.videoTexture).mediaPlayer.seekTo(pos - 8000);;
      }
      break;
    case KeyEvent.KEYCODE_DPAD_RIGHT:
      if (renderer != null && renderer.videoTexture != null) {
        int pos = ((MediaPlayerPlane)renderer.videoTexture).mediaPlayer.getCurrentPosition();
        ((MediaPlayerPlane)renderer.videoTexture).mediaPlayer.seekTo(pos + 8000);;
      }
      break;
    case KeyEvent.KEYCODE_SPACE:
      if (renderer != null && renderer.videoTexture != null) {
        if (((MediaPlayerPlane)renderer.videoTexture).mediaPlayer.isPlaying()) {
          ((MediaPlayerPlane)renderer.videoTexture).mediaPlayer.pause();
          glview.setSystemUiVisibility( View.SYSTEM_UI_FLAG_VISIBLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
        } else {
          ((MediaPlayerPlane)renderer.videoTexture).mediaPlayer.start();
          glview.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
        }
      }
      break;
    case KeyEvent.KEYCODE_C:
      if (renderer != null) {
        renderer.commentVisible = !renderer.commentVisible;
      }
      break;
    default:
      return super.onKeyDown(keyCode, event);
    }
    return true;
  }

}




Java Source Code List

net.binzume.android.glvideoplayer.DeviceCameraPlane.java
net.binzume.android.glvideoplayer.FBOTexture.java
net.binzume.android.glvideoplayer.GLShaderProgram.java
net.binzume.android.glvideoplayer.GLVideoRenderer.java
net.binzume.android.glvideoplayer.MainActivity.java
net.binzume.android.glvideoplayer.MediaPlayerPlane.java
net.binzume.android.glvideoplayer.NicoCommentPlane.java
net.binzume.android.glvideoplayer.OESTexture.java
net.binzume.android.glvideoplayer.TextureFactory.java
net.binzume.android.glvideoplayer.Texture.java
net.binzume.android.glvideoplayer.VideoSurfaceView.java
net.binzume.android.nicoplayer.player.CommentController.java
net.binzume.android.nicoplayer.player.CommentLoadTask.java
net.binzume.android.nicoplayer.player.CommentSlot.java
net.binzume.android.nicovideo.ChannelCategoryInfo.java
net.binzume.android.nicovideo.ChannelInfo.java
net.binzume.android.nicovideo.Comment.java
net.binzume.android.nicovideo.MyList.java
net.binzume.android.nicovideo.NicoSession.java
net.binzume.android.nicovideo.ThreadInfo.java
net.binzume.android.nicovideo.VideoFileInfo.java
net.binzume.android.nicovideo.VideoInfo.java
net.binzume.android.nicovideo.util.HtmlUtil.java
net.binzume.android.nicovideo.util.HttpClient.java
net.binzume.android.nicovideo.webapi.ChannelAPI.java
net.binzume.android.nicovideo.webapi.CommentAPI.java
net.binzume.android.nicovideo.webapi.Constants.java
net.binzume.android.nicovideo.webapi.FriendListAPI.java
net.binzume.android.nicovideo.webapi.LoginAPI.java
net.binzume.android.nicovideo.webapi.MyListAPI.java
net.binzume.android.nicovideo.webapi.NotLoginException.java
net.binzume.android.nicovideo.webapi.PaymentRequiredException.java
net.binzume.android.nicovideo.webapi.VideoAPI.java
net.binzume.android.nicovideo.webapi.VideoRssParser.java
net.binzume.android.nicovideo.webapi.VideoSearchAPI.java
net.binzume.android.nicovideo.webapi.WatchItemAPI.java
net.binzume.android.nicovideo.webapi.WebApiException.java