i am trying play a 3gp file ,which is having the video content but is getting work but not getting the video of that file,only able to hear the song,i tried with video view and tried with the surface also but still unable to execute ,can anybody help me???????????
Using java Syntax Highlighting
- package com.google.android.Videoplayer;
- import android.app.Activity;
- import android.graphics.PixelFormat;
- import android.media.MediaPlayer;
- import android.media.MediaPlayer.OnBufferingUpdateListener;
- import android.media.MediaPlayer.OnCompletionListener;
- import android.media.MediaPlayer.OnErrorListener;
- import android.os.Bundle;
- import android.util.Log;
- import android.view.Surface;
- import android.view.SurfaceHolder;
- import android.view.SurfaceView;
- import android.view.View;
- import android.webkit.URLUtil;
- import android.widget.EditText;
- import android.widget.ImageButton;
- import android.widget.VideoView;
- import java.io.File;
- import java.io.FileOutputStream;
- import java.io.IOException;
- import java.io.InputStream;
- import java.net.URL;
- import java.net.URLConnection;
- public class Videoplayer extends Activity implements SurfaceHolder.Callback {
- private static final String TAG = "VideoPlayer";
- private MediaPlayer mp;
- private SurfaceView mPreview;
- private SurfaceHolder holder;
- private ImageButton mPlay;
- private ImageButton mPause;
- private ImageButton mReset;
- private ImageButton mStop;
- /**
- * Called when the activity is first created.
- */
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- setContentView(R.layout.main);
- // Set up the play/pause/reset/stop buttons
- mPreview = (SurfaceView) findViewById(R.id.surface);
- mPlay = (ImageButton) findViewById(R.id.play);
- mPause = (ImageButton) findViewById(R.id.pause);
- mReset = (ImageButton) findViewById(R.id.reset);
- mStop = (ImageButton) findViewById(R.id.stop);
- mPlay.setOnClickListener(new View.OnClickListener() {
- public void onClick(View view) {
- playVideo();
- }
- });
- mPause.setOnClickListener(new View.OnClickListener() {
- public void onClick(View view) {
- if (mp != null) {
- mp.pause();
- }
- }
- });
- mReset.setOnClickListener(new View.OnClickListener() {
- public void onClick(View view) {
- if (mp != null) {
- mp.seekTo(0);
- }
- }
- });
- mStop.setOnClickListener(new View.OnClickListener() {
- public void onClick(View view) {
- if (mp != null) {
- mp.stop();
- mp.release();
- }
- }
- });
- // Set the transparency
- getWindow().setFormat(PixelFormat.TRANSPARENT);
- // Set a size for the video screen
- holder = mPreview.getHolder();
- holder.addCallback(this);
- holder.setFixedSize(320,400);
- }
- private void playVideo() {
- mp=MediaPlayer.create(Videoplayer.this, R.raw.crazy);
- mp.setAudioStreamType(3);
- mp.setDisplay(mPreview.getHolder().getSurface());
- mp.start();
- }
- public void surfaceCreated(SurfaceHolder surfaceholder) {
- Log.d(TAG, "surfaceCreated called");
- //return true;
- }
- public void surfaceChanged(SurfaceHolder surfaceholder, int i, int j, int k) {
- Log.d(TAG, "surfaceChanged called");
- }
- public void surfaceDestroyed(SurfaceHolder surfaceholder) {
- Log.d(TAG, "surfaceDestroyed called");
- }
- }
Parsed in 0.045 seconds, using GeSHi 1.0.8.4
this is the java file and XML file given below
Using xml Syntax Highlighting
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- >
- <SurfaceView android:id="@+id/surface"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent">
- </SurfaceView>
- <LinearLayout
- android:orientation="horizontal"
- android:layout_height="wrap_content"
- android:layout_width="fill_parent"
- >
- <ImageButton android:id="@+id/play"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:src="@drawable/play"/>
- <ImageButton android:id="@+id/pause"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:src="@drawable/pause"/>
- <ImageButton android:id="@+id/reset"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:src="@drawable/reset"/>
- <ImageButton android:id="@+id/stop"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:src="@drawable/stop"/>
- </LinearLayout>
- </LinearLayout>
Parsed in 0.005 seconds, using GeSHi 1.0.8.4
if anybody come across these thing please tell me mistake in the code or if anybody know how play a video file in that android SDKm5 please help me
hopefully......
with thanks bins....




I think i am not placing the 3gp file correctly. I have just placed it in a folder called data. Is that correct? Please let me know.