regarding playing mpeg4 & h.264 video file in android player

by root » Fri, 13 Feb 2009 18:16:15 GMT


Sponsored Links
 hi,
i have h.264&mp4 video file i am using following code but its giving
ioexception if any one know what is problem pls help me out.also there
is no folder called /raw in /res directory but some one written that we
need to place our video file in raw directory.can v place it any where
in file system & give path.

package org.anddev.android.musicplayer;
import java.io.*;

import android.app.Activity;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class MusicPlayer extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        setContentView(R.layout.main);
       
        // Find the Button from the xml-file.
        Button cmd_play = (Button)this.findViewById(R.id.cmd_play);
        cmd_play.setOnClickListener(new OnClickListener(){

               //@Override
               public void onClick(View arg0) {
                                        
                 
            MediaPlayer mp = new MediaPlayer();
                                   
            mp.setDataSource("/home/bugsbunny1.m4v");                           
                           
                mp.prepare();                                   
                                                                          
mp.start();                           
                  
// i.e. react on the end of the music-file:

                    mp.setOnCompletionListener(new
OnCompletionListener(){

                         // @Override
                         public void onCompletion(MediaPlayer arg0) {
                              // File has ended !!! Wink
                         }
                    });
               }
        });
    }
}                                  
                    
                                        
                                                
                                        
                  
                  
                  


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.


--~--~---------~--~----~------------~-------~--~----~



regarding playing mpeg4 & h.264 video file in android player

by Roman Romano » Fri, 13 Feb 2009 19:40:02 GMT


 why don't you just create a file called 'raw' in the 'res' folder????




--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


regarding playing mpeg4 & h.264 video file in android player

by root » Fri, 13 Feb 2009 20:22:33 GMT


 i tried that but it didn't worked for me.





-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.


--~--~---------~--~----~------------~-------~--~----~



regarding playing mpeg4 & h.264 video file in android player

by Dave Sparks » Sat, 14 Feb 2009 07:13:26 GMT


 he res directory inside your source tree does not equate to a
directory on the device. It's just a convention for telling the aapt
compiler what resources need to be included in the APK. Anything you
put in the res directory ends up zipped up inside the APK file along
with the Java code.

If you want to play from a resource file, use the MediaPlayer factory
function:

MediaPlayer mp = MediaPlayer.create(context, R.raw.bugsbunny1);
mp.start();

In your sample code, you use:

setDataSource("/home/bugsbunny1.m4v");

I can only guess this means you are trying to play the file from your
home directory on your host system. This will not work because the
emulator is running its own kernel and has its own file system. You
need to copy your file to the emulated SD card image using adb push
command.

On Feb 13, 4:24 am, root <gurur...@sarayusoftech.com> wrote:
--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Issue with plotting my location on Maps

Hi Android Champs!!!

I am currently facing an issue with my android application. The
application when executed displays a static map of north and south
america. I have created a menu option for displaying my current
location. When someone clicks on the menu "My Location" it executes a
method to display the current location. I have modified nader's NMaps2
application to handle this situation. I have written the
implementation for handling locations in the method
"displayMyLocation". I using the DDMS to manually set the location
coordinates. But when i pass the location and click at the menu, it
goes into an infinite loop. I would appreciate your help in fixing up
this code. The code i am using is as follows :


package com.android.ibsp.gps_isu;

import java.lang.ref.WeakReference;
import java.util.List;

import android.content.Context;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.location.LocationProvider;
import android.net.NetworkConnectivityListener;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.SubMenu;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import com.google.android.maps.MapActivity;
import com.google.common.android.AndroidConfig;
import com.google.googlenav.map.Map;
import com.google.googlenav.map.TrafficService;
import com.google.map.MapPoint;

public class IBSPApplication extends MapActivity implements
LocationListener
{
        private LocationManager mLocationManager= null;
    private LocationProvider mLocationProvider = null;


        public IBSPApplication()
    {
        mMap = null;
    }

    void setupMapView(com.android.ibsp.gps_isu.MapView mapView)
    {
        if(mMapView != null)
        {
            throw new IllegalStateException("You are only allowed to
have a single MapView in a MapActivity");
        } else
        {
            mDataRequestDispatcher.setProperty("key", mapView.mKey);
            mMapView = mapView;
            mMapView.setup(mMap, mTrafficService,
mDataRequestDispatcher);
            return;
        }
    }

    protected void onCreate(android.os.Bundle icicle)
    {
        super.onCreate(icicle);
        mNetworkWatcher = new NetworkConnectivityListener();
        mNetworkWatcher.registerHandler(mNetworkHandler, 0);
        mConfig = new AndroidConfig(this);
        com.google.common.Config.setConfig(mConfig);
        com.google.common.graphics.android.AndroidImage.mapResource("/
loading_tile.png", 0x108015f);
        com.google.common.graphics.android.AndroidImage.mapResource("/
blank_tile.png", 0x10800a2);
        com.google.common.graphics.android.AndroidImage.mapResource("/
no_tile_128.png", 0x108016f);
        createMap();

        LinearLayout zoomLayout = new LinearLayout(this);

        mMapView = new MapView(this, "IBSP");
        mMapView.setClickable(true);
        mMapView.setEnabled(true);

        mMapView.addView(zoomLayout, new
ViewGroup.LayoutParams(com.android.ibsp.gps_isu.MapView.LayoutParams.FILL_PARENT,
 
com.android.ibsp.gps_isu.MapView.LayoutParams.WRAP_CONTENT));
        zoomLayout.addView(mMapView.getZoomControls(),
                new
ViewGroup.LayoutParams(com.android.ibsp.gps_isu.MapView.LayoutParams.WRAP_CONTENT,
 
com.android.ibsp.gps_isu.MapView.LayoutParams.WRAP_CONTENT));

        setContentView(mMapView);
    }

    protected void onResume()
    {
        super.onResume();
        mTrafficService.start();
        mDataRequestDispatcher.start();
        mNetworkWatcher.startListening(this);
        mMap.resume();
    }

    protected void onPause()
    {
        super.onPause();
        if(sActivityReference.get() == this)
        {
            mTrafficService.stop();
            mMap.pause();
            mDataRequestDispatcher.stop();
            mNetworkWatcher.stopListening();
            mMap.saveState();
            mConfig.getPersistentStore().savePreferences();
        } else
        {
            android.util.Log.d("IBSP Application: ", (new
StringBuilder()).append("onPause leaving the lights on for
").append(sActivityReference.get()).toString());
        }
    }

    protected void onDestroy()
    {
        super.onDestroy();
        if(sActivityReference.get() == this)
        {
            mNetworkWatcher.unregisterHandler(mNetworkHandler);
            mNetworkWatcher = null;
            mTrafficService.close();
            mMap.close(false);
        } else
        {
            android.util.Log.d("IBSP Application: ", (new
StringBuilder()).append("onDestroy leaving the lights on for
").append(sActivityReference.get()).toString());
        }
        mConfig.getConnectionFactory().close();
    }

    private void createMap()
    {
        mDataRequestDispatcher =
com.google.common.DataRequestDispatcher.getInstance();
        if(mDataRequestDispatcher != null)
        {
            android.util.Log.w("IBSP Application: ", (new
StringBuilder()).append("Replacing old dispatcher
").append(mDataRequestDispatcher).toString());
            com.google.common.DataRequestDispatcher.clearInstance();
        }
        java.lang.String serverUrl = "http://www.google.com/glm/mmap/
a";
        java.lang.String version = "1.0.0";
        java.lang.String platformId = (new
StringBuilder("android:")).append(android.os.SystemProperties.get("ro.product.manufacturer",
"unknown").replace('-',
'_')).append("-").append(android.os.SystemProperties.get("ro.product.device",
"unknown").replace('-',
'_')).append("-").append(android.os.SystemProperties.get("ro.product.model",
"unknown").replace('-',
'_')).append("-").append(getClass().getName()).toString();
        java.lang.String distChannel =
android.os.SystemProperties.get("ro.com.google.clientid",
"android:unknown");
        mDataRequestDispatcher =
com.google.common.DataRequestDispatcher.createInstance(serverUrl,
platformId, version, distChannel);
        java.lang.String signature =
com.android.ibsp.gps_isu.KeyHelper.getSignatureFingerprint(super.getPackageManager(),
super.getPackageName());
        mDataRequestDispatcher.setProperty("sig", signature);
        com.google.map.MapPoint startPoint = null;
        com.google.map.Zoom zoom = null;
        int startingLatLng[] = getResources().getIntArray(0x1070006);
        startPoint = new MapPoint(startingLatLng[0],
startingLatLng[1]);
        int startingZoom[] = getResources().getIntArray(0x1070007);
        zoom = com.google.map.Zoom.getZoom(startingZoom[0]);
        mMap = sMapReference.get();
        if(mMap == null)
            mMap = new Map(null, 0x493e0, 0x30d40, 0x64000,
startPoint, zoom, 10);
        else
            android.util.Log.v("IBSP Application: ", "Recycling map
object.");
        sMapReference = new WeakReference<Map>(mMap);
        sActivityReference = new WeakReference<IBSPApplication>(this);
        mTrafficService = new TrafficService(0x1d4c0);
    }

    protected boolean isRouteDisplayed() {
        return false;
    }

    @SuppressWarnings("unchecked")
        protected boolean isLocationDisplayed()
    {
        if(mMapView == null)
            return false;
        java.util.List<MyLocationOverlay> overlays =
mMapView.getOverlays();
        for(java.util.Iterator<MyLocationOverlay> i =
overlays.iterator(); i.hasNext();)
        {
                com.android.ibsp.gps_isu.Overlay overlay = i.next();
            if((overlay instanceof
com.android.ibsp.gps_isu.MyLocationOverlay) &&
((com.android.ibsp.gps_isu.MyLocationOverlay)overlay).isMyLocationEnabled())
                return true;
        }
        return false;
    }

    private com.google.googlenav.map.TrafficService mTrafficService;
    private com.google.googlenav.map.Map mMap;
    private com.android.ibsp.gps_isu.MapView mMapView;
    private com.google.common.DataRequestDispatcher
mDataRequestDispatcher;
    private com.google.common.android.AndroidConfig mConfig;
    private android.net.NetworkConnectivityListener mNetworkWatcher;
    private static volatile java.lang.ref.WeakReference<Map>
sMapReference = new WeakReference<Map>(null);
    private static volatile
java.lang.ref.WeakReference<IBSPApplication> sActivityReference = new
WeakReference<IBSPApplication>(null);
    private final android.os.Handler mNetworkHandler = new
android.os.Handler() {

        public void handleMessage(android.os.Message message)
        {
            if(mNetworkWatcher == null)
                return;
            android.net.NetworkConnectivityListener.State state =
mNetworkWatcher.getState();
            android.util.Log.i("IBSP Application: ", (new
StringBuilder()).append("Handling network change
notification:").append(state.toString()).toString());
            if(mDataRequestDispatcher != null)
                if(state !=
android.net.NetworkConnectivityListener.State.CONNECTED)
                    mDataRequestDispatcher.stop();
                else
                    mDataRequestDispatcher.start();
            com.google.common.io.android.AndroidHttpConnectionFactory
factory;
            factory = mConfig.getConnectionFactory();
            if(factory == null)
            {
                android.util.Log.e("IBSP Application: ", "Couldn't get
connection factory");
                return;
            }
            com.google.android.net.GoogleHttpClient client;
            client = factory.getClient();
            if(client == null)
            {
                android.util.Log.e("IBSP Application: ", "Couldn't get
connection factory client");
                return;
            }
            org.apache.http.conn.ClientConnectionManager manager;
            manager = client.getConnectionManager();
            if(manager == null)
            {
                android.util.Log.e("IBSP Application: ", "Couldn't get
client connection manager");
                return;
            }
            try
            {
                manager.closeIdleConnections(1L,
java.util.concurrent.TimeUnit.MILLISECONDS);
            }
            catch(java.lang.Exception e)
            {
                android.util.Log.e("IBSP Application: ", "Couldn't
reset connection pool.", e);
            }

            return;
        }
    };

    private static final int MENU_ITEM_MAP_MODE = 10001;
    private static final int MENU_ITEM_MAP_MODE_SUB_MAP = 10002;
    private static final int MENU_ITEM_MAP_MODE_SUB_SATELLITE = 10003;
    private static final int MENU_ITEM_ZOOM = 10005;
    private static final int MENU_ITEM_MY_LOC = 10006;

    public boolean onCreateOptionsMenu(Menu pMenu) {
        super.onCreateOptionsMenu(pMenu);

        MenuItem menuItem = null;
        SubMenu subMenu = null;

        subMenu = pMenu.addSubMenu(Menu.NONE, MENU_ITEM_MAP_MODE,
            Menu.CATEGORY_SECONDARY, "Map mode");
        subMenu.setIcon(android.R.drawable.ic_menu_mapmode);

        menuItem = subMenu.add(0, MENU_ITEM_MAP_MODE_SUB_MAP,
Menu.NONE,
            "Map");
        menuItem.setAlphabeticShortcut('m');
        menuItem.setCheckable(true);
        menuItem.setChecked(false);

        menuItem = subMenu.add(0, MENU_ITEM_MAP_MODE_SUB_SATELLITE,
            Menu.NONE, "Satellite");
        menuItem.setAlphabeticShortcut('s');
        menuItem.setCheckable(true);
        menuItem.setChecked(false);

        menuItem = pMenu.add(0, MENU_ITEM_ZOOM,
Menu.CATEGORY_SECONDARY,
            "Zoom");
        menuItem.setAlphabeticShortcut('z');
        menuItem.setIcon(android.R.drawable.ic_menu_zoom);

        menuItem = pMenu.add(0, MENU_ITEM_MY_LOC,
Menu.CATEGORY_SECONDARY,
        "My Location");
        menuItem.setAlphabeticShortcut('l');
        menuItem.setIcon(android.R.drawable.ic_menu_mylocation);

        return true;
    }

    public boolean onOptionsItemSelected(MenuItem pItem) {
        switch (pItem.getItemId()) {

            case MENU_ITEM_MAP_MODE_SUB_MAP:
                mMapView.setSatellite(false);

                return true;

            case MENU_ITEM_MAP_MODE_SUB_SATELLITE:
                mMapView.setSatellite(true);

                return true;

            case MENU_ITEM_ZOOM:
                mMapView.displayZoomControls(true);

                return true;

            case MENU_ITEM_MY_LOC:
                displayMyLocation();

                return true;
        }

        return super.onOptionsItemSelected(pItem);
    }

    public boolean onPrepareOptionsMenu(Menu pMenu) {
        super.onPrepareOptionsMenu(pMenu);

        boolean isSatellite = mMapView.isSatellite();

        pMenu.findItem(MENU_ITEM_MAP_MODE_SUB_MAP)
            .setChecked(!isSatellite).setEnabled(isSatellite);
        pMenu.findItem(MENU_ITEM_MAP_MODE_SUB_SATELLITE)
            .setChecked(isSatellite).setEnabled(!isSatellite);

        return true;
    }


        @SuppressWarnings("unchecked")
        public void displayMyLocation(){
        android.util.Log.d("IBSP Application: ", "Display my location
started");

        mLocationManager =
(LocationManager)getSystemService(Context.LOCATION_SERVICE);
        Criteria criteria = new Criteria ();
        criteria.setAccuracy(Criteria.ACCURACY_FINE);
        List<String> providerIds =
mLocationManager.getProviders(criteria, true);
        if (!providerIds.isEmpty()){
                mLocationProvider =
mLocationManager.getProvider(providerIds.get(0));
        }
        setContentView(mMapView);

        MyLocationOverlay myLocationOverlay = new MyLocationOverlay
(this, mMapView);
        mMapView.getOverlays().add(myLocationOverlay);
        myLocationOverlay.enableMyLocation();
 
mLocationManager.requestLocationUpdates(mLocationProvider.getName(),
0, 0, this);
    }

        @Override
        public void onLocationChanged(Location location) {
                // TODO Auto-generated method stub
                updateView(location);
        }

        @Override
        public void onProviderDisabled(String provider) {
                // TODO Auto-generated method stub

        }

        @Override
        public void onProviderEnabled(String provider) {
                // TODO Auto-generated method stub

        }

        @Override
        public void onStatusChanged(String provider, int status, Bundle
extras) {
                // TODO Auto-generated method stub

        }
        private void updateView (Location location) {
        Double lat = location.getLatitude()*1E6;
        Double lng = location.getLongitude()*1E6;
        GeoPoint point = new GeoPoint(lat.intValue(),
lng.intValue());
        mMapView.getController().setCenter(point);
  }


}
--~--~---------~--~----~------------~-------~--~----~

2. how to disable the "back " key for the phone

My application needs to send several request to server. I don't want
user to click "back" key of the phone during  sending process.

Is there any way I can block it ?

If application is doing something, user click "back", what is the life
cycle of activity it would be?

Thanks!

April
--~--~---------~--~----~------------~-------~--~----~

3. Bitmap on sdcard & decodestream

4. Will there be an unfair ADC 2 having devs with and without hardware? - Hardware program for developers?

5. I need help in http connection???

6. Alignment issue related to ListView

7. : Help Needed