28package com.jogamp.opengl.demos.android;
30import java.net.HttpURLConnection;
31import java.net.URISyntaxException;
32import java.net.URLConnection;
33import java.util.Arrays;
35import com.jogamp.opengl.GLCapabilities;
36import com.jogamp.opengl.GLProfile;
37import com.jogamp.opengl.demos.av.MovieSimple;
39import jogamp.newt.driver.android.NewtBaseActivity;
41import com.jogamp.common.net.Uri;
42import com.jogamp.common.util.IOUtil;
43import com.jogamp.newt.NewtFactory;
44import com.jogamp.newt.Window;
45import com.jogamp.newt.event.MouseAdapter;
46import com.jogamp.newt.event.MouseEvent;
47import com.jogamp.newt.opengl.GLWindow;
48import com.jogamp.opengl.util.Animator;
49import com.jogamp.opengl.util.av.GLMediaPlayer;
50import com.jogamp.opengl.util.av.GLMediaPlayer.StreamException;
51import com.jogamp.opengl.util.texture.TextureSequence.TextureFrame;
53import android.os.Bundle;
54import android.util.Log;
57 static String TAG =
"MovieSimpleActivity0";
62 final Object src = e.getSource();
63 if(src instanceof
Window) {
64 ((
Window)src).requestFocus(
false);
69 public void onCreate(
final Bundle savedInstanceState) {
70 super.onCreate(savedInstanceState);
72 final String[] streamLocs =
new String[] {
73 System.getProperty(
"jnlp.media0_url0"),
74 System.getProperty(
"jnlp.media0_url1"),
75 System.getProperty(
"jnlp.media0_url2") };
76 final Uri streamLoc = getUri(streamLocs, 0,
false);
77 if(
null == streamLoc) {
throw new RuntimeException(
"no media reachable: "+Arrays.asList(streamLocs)); }
95 setContentView(getWindow(), glWindowMain);
96 anim.
add(glWindowMain);
104 public void attributesChanged(final GLMediaPlayer mp, final GLMediaPlayer.EventMask eventMask, final long when) {
105 System.err.println(
"MovieSimpleActivity0 AttributesChanges: "+eventMask+
", when "+when);
106 System.err.println(
"MovieSimpleActivity0 State: "+mp);
107 if( eventMask.isSet(GLMediaPlayer.EventMask.Bit.Init) ) {
108 glWindowMain.addGLEventListener(demoMain);
109 anim.setUpdateFPSFrames(60*5, System.err);
110 anim.resetFPSCounter();
112 if( eventMask.isSet(GLMediaPlayer.EventMask.Bit.Error) || eventMask.isSet(GLMediaPlayer.EventMask.Bit.EOS) ) {
113 final StreamException se = mPlayer.getStreamException();
115 se.printStackTrace();
117 getActivity().finish();
123 scrn.removeReference();
125 Log.d(TAG,
"onCreate - X");
128 static Uri getUri(
final String path[],
final int off,
final boolean checkAvail) {
130 for(
int i=off;
null==uri && i<path.length; i++) {
131 if(
null != path[i] && path[i].length()>0) {
133 final URLConnection uc = IOUtil.getResource(path[i],
null);
136 uri = Uri.valueOf(uc.getURL());
137 }
catch (
final URISyntaxException e) {
140 if( uc instanceof HttpURLConnection ) {
141 ((HttpURLConnection)uc).disconnect();
146 uri = Uri.cast(path[i]);
147 }
catch (
final URISyntaxException e) {
151 Log.d(TAG,
"Stream: <"+path[i]+
">: "+(
null!=uri));
void setBackgroundOpaque(final boolean opaque)
Sets whether the surface shall be opaque or translucent.
static Display createDisplay(final String name)
Create a Display entity.
static Screen createScreen(final Display display, final int index)
Create a Screen entity.
A screen may span multiple MonitorDevices representing their combined virtual size.
abstract int addReference()
See Display#addReference().
Pointer event of type PointerType.
An implementation of GLAutoDrawable and Window interface, using a delegated Window instance,...
final boolean setFullscreen(final boolean fullscreen)
Enable or disable fullscreen mode for this window.
final void setVisible(final boolean visible)
Calls setVisible(true, visible), i.e.
static GLWindow create(final GLCapabilitiesImmutable caps)
Creates a new GLWindow attaching a new Window referencing a new default Screen and default Display wi...
Specifies a set of OpenGL capabilities.
void setNumSamples(final int numSamples)
If sample buffers are enabled, indicates the number of buffers to be allocated.
void setSampleBuffers(final boolean enable)
Defaults to false.
Specifies the the OpenGL profile.
static GLProfile getGL2ES2(final AbstractGraphicsDevice device)
Returns the GL2ES2 profile implementation, hence compatible w/ GL2ES2.
void onCreate(final Bundle savedInstanceState)
Simple planar movie player w/ orthogonal 1:1 projection.
GLMediaPlayer getGLMediaPlayer()
void setUseOriginalScale(final boolean v)
final synchronized void add(final GLAutoDrawable drawable)
Adds a drawable to this animator's list of rendering drawables.
Specifying NEWT's Window functionality: