HI,
     I am trying to display a video file from a marker postion of google map
by clicking that .
I have done video code and the map code is like this .  i am new to android
Development  and tryied like this

java file

*************************************************
package com.ForMapDisplay;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;


import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.OverlayItem;



import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Point;
import android.location.Address;
import android.location.Geocoder;
import android.location.Location;
import android.location.LocationManager;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.LinearLayout;
import android.widget.MediaController;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.VideoView;
import android.widget.ViewSwitcher;


public class ForMapDisplay extends MapActivity {
    MapView mapView;
    MapController mc;
    GeoPoint[] eventLoc;
    GeoPoint[] feedLoc;

    VideoView vview;
    MediaController mediaController;
    TextView text_status;
    ViewSwitcher vswitcher;
    VideoView video_event;
    GeoPoint p;
    List<Overlay> listOfOverlays =null;


    GeoPoint[] getEventLocations () {

              return null;
    }

    GeoPoint[] getFeedLocations (GeoPoint evt) {
        int lt = evt.getLatitudeE6();
        int lg = evt.getLongitudeE6();
        GeoPoint[] gp = new GeoPoint[4];
        //getFeeds will need to contact server
        // for now lets have some points around the event
        // such as (lt+1, lg+1), (lt-1, lg-1), (lt-1, lg+1),(lt+1, lg-1)
        gp[0] = new GeoPoint (lt+1, lg+1);
        gp[1] = new GeoPoint (lt-1, lg-1);
        gp[2] = new GeoPoint (lt-1, lg+1);
        gp[3] = new GeoPoint (lt+1, lg-1);



        return gp;
    }





    public Address getAddressForLocation(Context context, Location location)
throws IOException {

        if (location == null) {
            return null;
        }
        double latitude = location.getLatitude();
        double longitude = location.getLongitude();
        int maxResults = 1;

        Geocoder gc = new Geocoder(context, Locale.getDefault());
        List<Address> addresses = gc.getFromLocation(latitude, longitude,
maxResults);

        if (addresses.size() == 1) {
            return addresses.get(0);
        } else {
            return null;
        }
    }





    class MapOverlay extends com.google.android.maps.Overlay
    {
        Context context;
        @Override
        public boolean draw(Canvas canvas, MapView mapView,
        boolean shadow, long when)
        {
            super.draw(canvas, mapView, shadow);
            Bitmap bmp = BitmapFactory.decodeResource(
                    getResources(),R.drawable.balloon37);
            context=mapView.getContext();
            LocationManager locationManager = (LocationManager)
getSystemService(Context.LOCATION_SERVICE);
         Location location =
locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
         canvas.drawBitmap (bmp, (float)location.getLatitude(),
(float)location.getLongitude(), null);
            return true;
            /*      //---translate the GeoPoint to screen pixels---
           Point[] pntArray = new Point[eventLoc.length];
            Point[] pntArray = new Point[eventLoc.length];
            for(int cnt=0; cnt<eventLoc.length; cnt++) {
                pntArray[cnt] = new Point();
                mapView.getProjection().toPixels(eventLoc[cnt],
pntArray[cnt]);
                canvas.drawBitmap (bmp, pntArray[cnt].x, pntArray[cnt].y -
50, null);
            }
            return true;*/
        }
        List<OverlayItem> list=new  ArrayList<OverlayItem>();
        protected boolean onTap(int index) {
              OverlayItem item = list.get(index);
              AlertDialog.Builder dialog = new
AlertDialog.Builder(mapView.getContext());
              dialog.setTitle(item.getTitle());
              dialog.setMessage(item.getSnippet());
              dialog.show();
              onClick(mapView);
              return true;
            }






     /*...@override
    protected boolean onTap(int value) {
        ArrayList<OverlayItem> myOverlays = new ArrayList<OverlayItem>();
        String filename = "famous.3gp";
        Context mContext = null;  // need to pass file name
        OverlayItem item = myOverlays.get(value);
        AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
        dialog.setTitle(item.getTitle());
        dialog.setMessage(item.getSnippet());
        dialog.show();
      return true;
    }*/

   // @Override
    public boolean onTouchEvent(MotionEvent event, MapView mapView)
    {
        //TO-DO here we will capture when the users
        //has pointed a point to go..
        if(event.getAction() != MotionEvent.ACTION_MOVE){
            GeoPoint p = mapView.getProjection().fromPixels(
                    (int) event.getX(),
                    (int) event.getY());

                Geocoder geoCoder = new Geocoder(
                    getBaseContext(), Locale.getDefault());
                try {
                    List<Address> addresses = geoCoder.getFromLocation(
                        p.getLatitudeE6()  / 1E6,
                        p.getLongitudeE6() / 1E6, 1);

                    String add = "";
                    if (addresses.size() > 0)
                    {
                        for (int i=0;
i<addresses.get(0).getMaxAddressLineIndex();
                             i++)
                           add += addresses.get(0).getAddressLine(i) + "\n";
                    }
                    Log.e("##################",
                            "screen touched: lat:"+(p.getLatitudeE6()/
1E6)+"long:"+(p.getLongitudeE6()/ 1E6));
             //       showMap((p.getLatitudeE6()/ 1E6),(p.getLongitudeE6()/
1E6));
                    Toast.makeText(getBaseContext(), add,
Toast.LENGTH_SHORT).show();
                }
                catch (IOException e) {
                    e.printStackTrace();
                }
                return true;
        }else
            return false;
    }


    public void onClick(View v) {

        vswitcher.showNext();
        text_status.setText("Video Play");
        String FICHIER_BLOW = "famous.3gp";
        File f = new
File(Environment.getExternalStorageDirectory(),FICHIER_BLOW);
        Log.i("per write: ", f.canWrite() + "");
        Log.i("per read : ", f.canRead() + "");
        Log.i("change made : ", "change made in code");
        mediaController.setAnchorView(video_event);
        Uri video = Uri.fromFile(f);
        video_event.setMediaController(mediaController);
        video_event.setVideoURI(video);
        video_event.start();
    }

    }

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mapView = (MapView) findViewById(R.id.mapView);
        vswitcher = (ViewSwitcher) findViewById(R.id.switcher);
        video_event = (VideoView) findViewById (R.id.video_event);
        LinearLayout zoomLayout = (LinearLayout)findViewById(R.id.zoom);
        // replace this with setBuiltInZoom...
        View zoomView = mapView.getZoomControls();


        zoomLayout.addView(zoomView,
            new LinearLayout.LayoutParams(
                LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT));
        mapView.displayZoomControls(true);
        // up to this can be removed

        mc.setZoom(17);

        vview = (VideoView) findViewById(R.id.surface_view);


        // get all event locations
        // add to event overlay
        GeoPoint point = new GeoPoint(19240000,-99120000);
        OverlayItem overlayitem = new OverlayItem(point, "Narendra!", "I'm
in Mexico City!");


        MapOverlay mapOverlay = new MapOverlay();
        listOfOverlays = mapView.getOverlays();
        listOfOverlays.clear();

        listOfOverlays.add(mapOverlay);

        /*MyItemizedOverlay overlay = new MyItemizedOverlay(icon);
        OverlayItem item = new OverlayItem(gp, "My Location", null);
        overlay.addItem(item);
        myMap.getOverlays().add(overlay);

*/
        GeoPoint point = new GeoPoint(latitude,longitude);

        HelloItemizedOverlay itemizedoverlay = new
HelloItemizedOverlay(drawable);    //inserting pin in the constructor

        itemizedoverlay.addPoint(point);

        mapOverlays.add(itemizedoverlay);



         mapView.invalidate();

        final Intent myIntent = new
Intent(android.content.Intent.ACTION_VIEW,
                Uri.parse("geo:0,0?q=http://code.google.com/famous.3gp";));
                startActivity(myIntent);


    }

    @Override
    protected boolean isRouteDisplayed() {
        // TODO Auto-generated method stub
        return false;
    }
}

******************************** XML
file****************************************************************

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android";
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<com.google.android.maps.MapView
        android:id="@+id/mapView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:enabled="true"
        android:clickable="true"
        android:apiKey="0l-0DLqA6E3p2mKxv2JxTxov2XhyESIG6cO6ETQ"

        />
        <LinearLayout android:id="@+id/zoom"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        />
    <ViewSwitcher android:layout_height="540dip"
android:layout_width="700dip" android:layout_y="5dip"
android:layout_x="145dip" android:id="@+id/switcher">
 <LinearLayout android:id="@+id/LinearLayout01"
        android:layout_width="wrap_content"
android:layout_height="wrap_content">
        <VideoView android:id="@+id/surface_view"
            android:layout_height="120px" android:layout_width="fill_parent"
/>
    </LinearLayout>
    <LinearLayout android:id="@+id/LinearLayout02"
        android:layout_width="wrap_content"
android:layout_height="wrap_content">
        <TextView android:id="@+id/TextView02"
android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:text="Record
"></TextView>
        <Button android:id="@+id/Button01" android:layout_height="30px"
            android:layout_width="30px"
android:background="@drawable/bfz004"></Button>
        <Button android:id="@+id/Button02" android:layout_height="30px"
            android:layout_width="30px"
android:background="@drawable/bfz006"
            android:focusable="false"></Button>
        <Button android:id="@+id/Button03" android:text="Save"
            android:layout_height="30px" android:layout_width="30px"
            android:background="@drawable/bfz0078"></Button>
        <Button android:id="@+id/Button04" android:text="Cancel"
            android:layout_height="30px"
android:background="@drawable/bfz0078"
            android:layout_width="50px"></Button>
        <TextView android:id="@+id/TextView03"
android:layout_width="wrap_content"
            android:layout_height="wrap_content"></TextView>

        <VideoView android:id="@+id/video_event"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></VideoView>
    </LinearLayout>
    </ViewSwitcher>

</RelativeLayout>



****************************************************


and i need  like this in overlay and calling video from some other file can
any one of you provide solution for this



// Having  an EventOverlay and add events to it
    // EventOverlayItem will have event location as context
    // EventOverlay will contain onTap or onClick
        // get location from context
        // get feeds
        // add feeds to the FeedOverlay
    // then invalidate mapview
    // addItem will take location as argument


    // Have a FeedOverlay and add feeds to it
    // FeedOverlay will contain onTap or onClick will get us to the feed
video
    // FeedOverlayItem will have the filename as context
    // need to pass a URI - for now just pass the file name
    // filename should be argument to every FeedOverlayItem
    // addItem method will take location and filename as argument

    // The below should be part of FeedOverlay
    // String filename = "famous.3gp";

    // get view switcher using findViewById
    // vswitcher.showNext();
    // get the video view using findViewById
    // same sequence as displayVideo
    // get URI for file, set Video URI, start
    // call setVideoURI with appropriate filename

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to