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

  • Home
  • SEARCH
  • 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 7928827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T19:51:45+00:00 2026-06-03T19:51:45+00:00

I’m trying to do some video playback with a very simple code, and no

  • 0

I’m trying to do some video playback with a very simple code, and no matter what I change, I’m getting always the same problem: The last line on onCreate and onResume is called, but nothing else is called and Activity finishes with an uncaught exception, before calling surfaceCreated.
What am I doing wrong?

import java.io.File;
import java.io.IOException;

import android.app.Activity;
import android.content.pm.ActivityInfo;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.SurfaceHolder;
import android.view.SurfaceView;


public class VideoPlayerActivity extends Activity implements SurfaceHolder.Callback {

private MediaPlayer mMediaPlayer;
private SurfaceView vview;
private SurfaceHolder holder;
private String videoPath;
private String id;

@Override
public void onCreate(Bundle icicle) {

    super.onCreate(icicle);
    setContentView(R.layout.videoplayer);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    System.out.println("Inside VideoPlayerActivity.");

    vview = (SurfaceView) findViewById(R.id.vplay_surface);
    holder = vview.getHolder();
    holder.addCallback(this);
    holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);

    System.out.println("Surface and holder configured.");

    //Bundle dungle = getIntent().getExtras();
    //id = dungle.getString("id");
    id = "1";

    videoPath = getFilesDir().getAbsolutePath().toString() + File.separator + "VID" + id + ".mp4";
    System.out.println("PATH: " + videoPath);
    //iniElements();

    } 

@Override
public void onResume() {
    iniElements();
}

private void iniElements() {

    mMediaPlayer = new MediaPlayer();
    System.out.println("MediaPlayer object created.");

    } 

private void iniPlayer() {

    System.out.println("Initiating player!");

    try {
    mMediaPlayer.setDataSource(videoPath);
    mMediaPlayer.prepare();
    } catch (IllegalArgumentException e) {
    e.printStackTrace();
    } catch (IllegalStateException e) {
    e.printStackTrace();
    } catch (IOException e) {
    e.printStackTrace();
    }

    mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
    mMediaPlayer.start();

    System.out.println("Reached START PLAYER.");

}

@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width,
        int height) {
    System.out.println("Surface changed.");

}

@Override
public void surfaceCreated(SurfaceHolder holder) {

    System.out.println("Surface created!");
    try {
        mMediaPlayer.setDisplay(holder);
    } catch (Exception e) {
        e.printStackTrace();
    }
    System.out.println("Elements configured.");

    iniPlayer();

}

@Override
public void surfaceDestroyed(SurfaceHolder holder) {
    System.out.println("Surface destroyed.");

}

@Override
public void onPause() {
    System.out.println("Activity on pause.");
}


@Override
public void onDestroy () {
    System.out.println("Destroying activity.");
}


}

And the xml file is as simple as:

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

  <RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="268dp"
        android:layout_height="202dp"
        android:layout_marginTop="10dp"
        android:layout_gravity="center"
        android:orientation="horizontal" >

        <SurfaceView
            android:id="@+id/vplay_surface"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:scaleType="centerInside"
        android:gravity="center" />

  </RelativeLayout>

 </LinearLayout>

Logcat says:

05-06 16:39:51.286: INFO/power(2083): *** acquire_dvfs_lock : lockType : 1  freq : 1200000 
05-06 16:39:51.286: INFO/ActivityManager(2083): START {intent.toShortString} from pid 18751
05-06 16:39:51.286: DEBUG/PowerManagerService(2083): acquireDVFSLockLocked : type : DVFS_MIN_LIMIT  frequency : 1200000  uid : 1000  pid : 2083  tag : ActivityManager
05-06 16:39:51.286: WARN/ActivityManager(2083): mDVFSLock.acquire()
  05-06 16:39:51.306: DEBUG/ActivityManager(2083): Trying to launch applicationName
  05-06 16:39:51.326: DEBUG/AndroidRuntime(18751): Shutting down VM
  05-06 16:39:51.326: WARN/dalvikvm(18751): threadid=1: thread exiting with uncaught exception (group=0x40c341f8)
  05-06 16:39:51.331: WARN/ActivityManager(2083):   Force finishing activity r.intent.getComponent().flattenToShortString()
05-06 16:39:51.336: VERBOSE/yamaha::media::VolumeCtrl(1833): VolumeCtrl::createVolume()
05-06 16:39:51.336: DEBUG/yamaha::media::VolumeCtrl(1833): Dir0      : AP Playback Music SP (0001h)
05-06 16:39:51.336: DEBUG/yamaha::media::VolumeCtrl(1833): Dir0Att   : AP Playback Music SP (0001h)
05-06 16:39:51.336: DEBUG/yamaha::media::VolumeCtrl(1833): DacMaster : AP Playback Music SP (0001h)
05-06 16:39:51.336: DEBUG/yamaha::media::VolumeCtrl(1833): Sp        : AP Playback Music SP (FD81h)
05-06 16:39:51.336: VERBOSE/yamaha::media::VolumeCtrl(1833): VolumeCtrl::setVolume()
05-06 16:39:51.336: DEBUG/yamaha::media::VolumeCtrl(1833): VolumeCtrl::setVolume() FM Playback: Ready
05-06 16:39:51.336: DEBUG/yamaha::media::VolumeCtrl(1833): VolumeCtrl::setVolume() VoiceCall: Ready
05-06 16:39:51.336: WARN/ActivityManager(2083):   Force finishing activity r.intent.getComponent().flattenToShortString()
05-06 16:39:51.351: INFO/dumpstate(18883): Check if stand-alone
05-06 16:39:51.356: INFO/dumpstate(18883): begin
05-06 16:39:51.401: INFO/ALSAModule(1833): Initialized ALSA PLAYBACK device hifi
05-06 16:39:51.641: INFO/AudioPolicyManager(1833): stopOutput() output 1, stream 1, session 2190
05-06 16:39:51.681: INFO/AudioFlinger(1833): stop output streamType (0, 1) for 1
05-06 16:39:51.836: WARN/ActivityManager(2083): Activity pause timeout for r

Thanks in advance!

  • 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-03T19:51:47+00:00Added an answer on June 3, 2026 at 7:51 pm

    OK I found the problem. The problem is that you cannot open a file inside /data/data/package in such manner. You have to first create a FileInputStream with openFileInput() and then create a File with reference to the FileInputStream; then you can use that File to get its File Descriptor and pass it to the player.
    If you want to see the code, please ask for it, I will share it.
    Cheers

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
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 a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am doing a simple coin flipping experiment for class that involves flipping a
I am trying to render a haml file in a javascript response like so:
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.