Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8281563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T10:04:39+00:00 2026-06-08T10:04:39+00:00

I’ve been struggling with this for 2 days now… Following this answer: https://stackoverflow.com/a/2006454/444324 –

  • 0

I’ve been struggling with this for 2 days now…
Following this answer: https://stackoverflow.com/a/2006454/444324 – it is mentioned that it’s possible to play a video in a GLSurfaceView by altering the MediaPlayerDemo_Video example in API Demos:

All you have to do there is to replace the SurfaceView with a
GLSurfaceView in both the MediaPlayerDemo_Video.java file as well as
in the corresponding layout file (mediaplayer_2.xml).

Also you need to create a custom Renderer class (one that implements
the GLSurfaceView.Renderer interface) and set it to your
GLSurfaceView.

I tried replacing the SurfaceView to a GLSurfaceView as suggested, also using this but it just crashes on start:

07-11 14:54:22.086: E/AndroidRuntime(12373): FATAL EXCEPTION: main
07-11 14:54:22.086: E/AndroidRuntime(12373): java.lang.NullPointerException
07-11 14:54:22.086: E/AndroidRuntime(12373):    at android.opengl.GLSurfaceView.surfaceCreated(GLSurfaceView.java:512)
07-11 14:54:22.086: E/AndroidRuntime(12373):    at android.view.SurfaceView.updateWindow(SurfaceView.java:533)
07-11 14:54:22.086: E/AndroidRuntime(12373):    at android.view.SurfaceView.access$000(SurfaceView.java:81)
07-11 14:54:22.086: E/AndroidRuntime(12373):    at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:169)
07-11 14:54:22.086: E/AndroidRuntime(12373):    at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:590)
07-11 14:54:22.086: E/AndroidRuntime(12373):    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1617)
07-11 14:54:22.086: E/AndroidRuntime(12373):    at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2442)
07-11 14:54:22.086: E/AndroidRuntime(12373):    at android.os.Handler.dispatchMessage(Handler.java:99)
07-11 14:54:22.086: E/AndroidRuntime(12373):    at android.os.Looper.loop(Looper.java:137)
07-11 14:54:22.086: E/AndroidRuntime(12373):    at android.app.ActivityThread.main(ActivityThread.java:4575)
07-11 14:54:22.086: E/AndroidRuntime(12373):    at java.lang.reflect.Method.invokeNative(Native Method)
07-11 14:54:22.086: E/AndroidRuntime(12373):    at java.lang.reflect.Method.invoke(Method.java:511)
07-11 14:54:22.086: E/AndroidRuntime(12373):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
07-11 14:54:22.086: E/AndroidRuntime(12373):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
07-11 14:54:22.086: E/AndroidRuntime(12373):    at dalvik.system.NativeStart.main(Native Method)

I know I can use a VideoView to play a video or just stay with SurfaceView with MediaPlayer but I must use a GLSurfaceView because I need this video to be played on top of the camera surface view.

Thank you!

Relevant code:
my XML:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <com.commonsware.android.camera.MyGLSurfaceView
        android:id="@+id/surface"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center" />

</LinearLayout>

My Class:

public class MediaPlayerDemo_Video extends Activity implements
        OnBufferingUpdateListener, OnCompletionListener,
        OnPreparedListener, OnVideoSizeChangedListener, SurfaceHolder.Callback {

    private MediaPlayer mMediaPlayer;
    private MyGLSurfaceView mPreview;
    private SurfaceHolder holder;

    /**
     * 
     * Called when the activity is first created.
     */
    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        setContentView(R.layout.mediaplayer_2);
        mPreview = (MyGLSurfaceView) findViewById(R.id.surface);
        holder = mPreview.getHolder();
        holder.addCallback(this);
        holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);

    }
}

MyGLSurfaceView Class:

class MyGLSurfaceView extends android.opengl.GLSurfaceView {
    public MyGLSurfaceView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T10:04:41+00:00Added an answer on June 8, 2026 at 10:04 am

    OK, solved this… I had several errors but the final error I present in my question is solved by adding this code to the onCreate:

    mPreview.setRenderer(new Renderer() {
    
                @Override
                public void onSurfaceCreated(GL10 gl, EGLConfig config) {
                    // TODO Auto-generated method stub
    
                }
    
                @Override
                public void onSurfaceChanged(GL10 gl, int width, int height) {
                    // TODO Auto-generated method stub
    
                }
    
                @Override
                public void onDrawFrame(GL10 gl) {
                    // TODO Auto-generated method stub
    
                }
            });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Does anyone know how can I replace this 2 symbol below from the string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.