28package com.jogamp.opengl.demos.androidfat;
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.android.LauncherUtil.OrderedProperties;
38import com.jogamp.opengl.demos.av.MovieSimple;
40import jogamp.newt.driver.android.NewtBaseActivity;
42import com.jogamp.common.net.Uri;
43import com.jogamp.common.util.IOUtil;
44import com.jogamp.newt.NewtFactory;
45import com.jogamp.newt.Window;
46import com.jogamp.newt.event.MouseAdapter;
47import com.jogamp.newt.event.MouseEvent;
48import com.jogamp.newt.opengl.GLWindow;
49import com.jogamp.opengl.util.Animator;
50import com.jogamp.opengl.util.av.GLMediaPlayer;
51import com.jogamp.opengl.util.av.GLMediaPlayer.StreamException;
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);
70 props.
setProperty(
"jnlp.media0_url0",
"https://archive.org/download/BigBuckBunny_328/BigBuckBunny_512kb.mp4");
71 props.
setProperty(
"jnlp.media1_url1",
"https://archive.org/download/ElephantsDream/ed_1024_512kb.mp4");
72 props.
setProperty(
"jnlp.media0_url2",
"file:///mnt/sdcard/Movies/BigBuckBunny_320x180.mp4");
83 props.
setProperty(
"jogl.debug.GLMediaPlayer",
"true");
98 public void onCreate(
final Bundle savedInstanceState) {
99 Log.d(TAG,
"onCreate - 0");
103 super.onCreate(savedInstanceState);
105 final String[] streamLocs =
new String[] {
106 System.getProperty(
"jnlp.media0_url0"),
107 System.getProperty(
"jnlp.media0_url1"),
108 System.getProperty(
"jnlp.media0_url2") };
109 final Uri streamLoc = getUri(streamLocs, 0,
false);
110 if(
null == streamLoc) {
throw new RuntimeException(
"no media reachable: "+Arrays.asList(streamLocs)); }
118 Log.d(TAG,
"req caps: "+capsMain);
130 setContentView(getWindow(), glWindowMain);
131 anim.
add(glWindowMain);
139 public void attributesChanged(final GLMediaPlayer mp, final GLMediaPlayer.EventMask eventMask, final long when) {
140 System.err.println(
"MovieSimpleActivity0 AttributesChanges: "+eventMask+
", when "+when);
141 System.err.println(
"MovieSimpleActivity0 State: "+mp);
142 if( eventMask.isSet(GLMediaPlayer.EventMask.Bit.Init) ) {
143 glWindowMain.addGLEventListener(demoMain);
144 anim.setUpdateFPSFrames(60*5, System.err);
145 anim.resetFPSCounter();
147 if( eventMask.isSet(GLMediaPlayer.EventMask.Bit.Error) || eventMask.isSet(GLMediaPlayer.EventMask.Bit.EOS) ) {
148 final StreamException se = mPlayer.getStreamException();
150 se.printStackTrace();
152 getActivity().finish();
158 scrn.removeReference();
160 Log.d(TAG,
"onCreate - X");
163 static Uri getUri(
final String path[],
final int off,
final boolean checkAvail) {
165 for(
int i=off;
null==uri && i<path.length; i++) {
166 if(
null != path[i] && path[i].length()>0) {
168 final URLConnection uc = IOUtil.getResource(path[i],
null);
171 uri = Uri.valueOf(uc.getURL());
172 }
catch (
final URISyntaxException e) {
175 if( uc instanceof HttpURLConnection ) {
176 ((HttpURLConnection)uc).disconnect();
181 uri = Uri.cast(path[i]);
182 }
catch (
final URISyntaxException e) {
186 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.
final void setProperty(final String key, final String value)
final void setSystemProperties()
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: