I think you might have a look to the example provided by Android SDK regarding a <a href=" http://developer.android.com/guide/samples/ApiDemos/src/com/example/android/apis/media/VideoViewDemo.html">VideoPlayer</a>. Here is the code I use:
videoview.xml in /res/layout <?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" > <VideoView android:id="@+id/surface_view" android:layout_width="320px" android:layout_height="240px" /> </LinearLayout> CODE <b>package com.example.android.apis.media; import com.example.android.apis.R;</b> import android.app.Activity; import android.graphics.PixelFormat; import android.net.Uri; import android.os.Bundle; import android.util.Log; import android.widget.MediaController; import android.widget.Toast; import android.widget.VideoView; public class VideoViewDemo extends Activity { /** * TODO: Set the path variable to a streaming video URL or a local media * file path. */ private String path = "rtsp://rtsp2.youtube.com/ CjcLENy73wIaLgmVcsAQigQC- xMYDSANFEITVUdlbnQtWW91VHViZURlbW8tMUgGUgZ2aWRlb3MM/0/0/0/video.3gp"; private VideoView mVideoView; @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.videoview); mVideoView = (VideoView) findViewById(R.id.surface_view); if (path == "") { // Tell the user to provide a media file URL/path. Toast.makeText( VideoViewDemo.this, "Please edit VideoViewDemo Activity, and set path" + " variable to your media file URL/path", Toast.LENGTH_LONG).show(); } else { /* * Alternatively,for streaming media you can use * mVideoView.setVideoURI(Uri.parse(URLstring)); */ mVideoView.setVideoPath(path); mVideoView.setMediaController(new MediaController(this)); mVideoView.requestFocus(); } } } package com.wica.media; import com.wica.facetube.R; import android.app.Activity; import android.graphics.PixelFormat; import android.net.Uri; import android.os.Bundle; import android.util.Log; import android.widget.MediaController; import android.widget.Toast; import android.widget.VideoView; public class Player extends Activity { private String path = "rtsp://rtsp2.youtube.com/ CjcLENy73wIaLgmVcsAQigQC- xMYDSANFEITVUdlbnQtWW91VHViZURlbW8tMUgGUgZ2aWRlb3MM/0/0/0/video.3gp"; private VideoView mVideoView; // public Player (String path){ // this.path = path; // } @Override public void onCreate(Bundle icicle) { Log.v("init","dentro de Player"); super.onCreate(icicle); setContentView(R.layout.videoview); mVideoView = (VideoView) findViewById(R.id.surface_view); // Alternatively,for streaming media you can use mVideoView.setVideoURI(Uri.parse(URLstring)); mVideoView.setVideoPath(this.getIntent().getDataString()); mVideoView.setMediaController(new MediaController(this)); mVideoView.requestFocus(); } } On Jun 17, 4:56 pm, Vinayakumara T V <vnykm...@gmail.com> wrote: > Hi All, > I am writing an application to play the youtube videos usingstreaming. > > First method: > I am getting the RTSP URL to the video using GData APIs. > Here is the code to play the RTSP url. > > VideoView mVideoView = new VideoView(this); > setContentView(mVideoView); > mVideoView.setVideoURI(Uri.parse("rtsp://rtsp2.youtube.com/CiILENy73wIaGQkDwpjrUxOWQBMYESARFEgGUgZ2aWRlb3MM/0/0/0/video.3gp")); > mVideoView.start(); > > But it throws error on both G1 device and emulator (Emulator has some > firewall problem as per mailing list) > Here is the error message > > ERROR/PlayerDriver(35): Command PLAYER_INIT completed with an error or > info PVMFFailure > > Second method: > A hack way to get the path of 3gp file > fromhttp://www.youtube.com/get_video?v=<VideoID>&t=<>&<>.. > After getting the file path and I can call setVideoURI and it plays > fine. But it is a hack way to achieve the requirement. > I have checked the Youtube App also, it also does the hack way to play > the youtube url.(Checked with logcat) > > I have tried changing from VideoView to MediaPlayer but no change in the > error. > > Is there a "Clean" way to do this? > > Please let me know your thoughts. > > With RegardsVinayakumaraT V --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "android-framework" group. To post to this group, send email to android-framework@googlegroups.com To unsubscribe from this group, send email to android-framework+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-framework?hl=en -~----------~----~----~----~------~----~------~--~---