MediaPlayer Video Problem

All your problems with Audio, Video and Images.

MediaPlayer Video Problem

Postby Merlino » Wed Jan 20, 2010 11:17 am

Hi, I have a little (big) problem to start a video with the MediaPlayer.

When I am starting the app, the Video should be played. But I can only hear the Sound.
I know that the solution for this Problem is to use the SurfaceHolder. But I am already using it.

I don't know if there is missing something in my Code or if the problem is somewhere else.
I already searched for solutions in this forum and with google, but i did not found any differences in the code structure.


This is my LayoutFile:
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2.  
  3. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  4.  
  5.    android:orientation="vertical"
  6.  
  7.    android:layout_width="fill_parent"
  8.  
  9.    android:layout_height="fill_parent">
  10.  
  11.  
  12.  
  13.         <SurfaceView
  14.  
  15.                 android:id="@+id/surface"
  16.  
  17.                 android:layout_width="250px"
  18.  
  19.                 android:layout_height="250px"
  20.  
  21.                 android:layout_gravity="center">
  22.  
  23.         </SurfaceView>
  24.  
  25.  
  26.  
  27. </LinearLayout>
Parsed in 0.003 seconds, using GeSHi 1.0.8.4



and this my ActivityClass:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. public class Mainmenu extends Activity{
  3.  
  4.        
  5.  
  6.     private static final String TAG = "MediaPlayerDemo";
  7.  
  8.     private MediaPlayer mMediaPlayer;
  9.  
  10.     private SurfaceView mPreview;
  11.  
  12.     private SurfaceHolder holder;
  13.  
  14.  
  15.  
  16.     @Override
  17.  
  18.     public void onCreate(Bundle savedInstanceState) {
  19.  
  20.         super.onCreate(savedInstanceState);
  21.  
  22.         setContentView(R.layout.main);
  23.  
  24.        
  25.  
  26.         mPreview = (SurfaceView) findViewById(R.id.surface);
  27.  
  28.         holder = mPreview.getHolder();
  29.  
  30.         holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
  31.  
  32.      
  33.  
  34.         try
  35.  
  36.         {
  37.  
  38.          mMediaPlayer = MediaPlayer.create(this, R.raw.test);
  39.  
  40.          mMediaPlayer.setDisplay(holder);
  41.  
  42.          mMediaPlayer.start();
  43.  
  44.         }
  45.  
  46.        
  47.  
  48.        catch(Exception e){Log.e(TAG, "error: " + e.getMessage(), e);}
  49.  
  50.        }
  51.  
  52.     }
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
Parsed in 0.034 seconds, using GeSHi 1.0.8.4


I only want to know how to start a Video.
There is no error an no exception. The file is in the raw Folder and i can hear the sound without Problems.
I tried it with an mp4 and an 3gp videofile. The 3gp was captured with an G1.
And it makes no difference if i start the app with an emulator or with my G1.
So there must be something wrong with my code... but i dont know what.
Merlino
Freshman
Freshman
 
Posts: 3
Joined: Wed Jan 20, 2010 10:21 am

Top

Postby desuvinodkumar » Sat Jan 23, 2010 2:55 pm

HI

FYI

mMediaPlayer.setDataSource(FilePAth);


in try block......

it may works....

TIA
Vinod...
User avatar
desuvinodkumar
Senior Developer
Senior Developer
 
Posts: 102
Joined: Mon Mar 23, 2009 6:51 am
Location: India

Postby Beros_ » Fri Jan 29, 2010 5:10 pm

Hi!

Is there any way to set video playback speed so video would play with speed 120%, 200% 20% or backwards -20% -100% ???

When I use command video.seekto(ms) while video is paused, it doesn't want to show that frame, until i call video.start(). But I don't want to play video from that frame, only set current frame and render it. I found great problems with using video.pause() command.

What to do to set video update image/frame when video is paused and I set frame with video.seekto(ms) command?

Thanks
Beros_
Freshman
Freshman
 
Posts: 7
Joined: Fri Jan 29, 2010 4:29 pm
Location: Croatia

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: Yahoo [Bot] and 15 guests