path will not work because Android is not Windows and does not have a C: drive.
path2 may not work -- I am under the impression that playing back video from a resource is problematic. Here is a project that will play back a test.mp4 video located in the root of external storage -- you can put a file there via DDMS's file manager: https://github.com/commonsguy/cw-advandroid/tree/master/Media/Video On Tue, Jan 18, 2011 at 8:19 AM, bob <b...@coolgroups.com> wrote: > Can someone help me figure out how to play video on Android? I can't > figure out how to refer to the 3gp resource that I added to the > project. Here's what I've been trying: > > /* > * Copyright (C) 2009 The Android Open Source Project > * > * Licensed under the Apache License, Version 2.0 (the "License"); > * you may not use this file except in compliance with the License. > * You may obtain a copy of the License at > * > * http://www.apache.org/licenses/LICENSE-2.0 > * > * Unless required by applicable law or agreed to in writing, software > * distributed under the License is distributed on an "AS IS" BASIS, > * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or > implied. > * See the License for the specific language governing permissions and > * limitations under the License. > */ > > package com.example.android.apis.media; > > import java.net.URI; > > import com.example.android.apis.R; > import android.app.Activity; > import android.net.Uri; > import android.os.Bundle; > 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 = "C:\\Program Files\\BloodRayne2 Demo\\video\ > \logh.mpg"; > 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)); > */ > > //Uri path2 = Uri.parse("android.resource:// > com.example.android/raw/tempire"); > > //Uri path2 = Uri.parse("android.resource:// > com.example.android.apis.media/" + R.raw.tempire); > > Uri path2 = Uri.parse("android.resource://apidemos/raw/ > tempire"); > > mVideoView.setVideoURI(path2); > //mVideoView.setVideoPath(path); > mVideoView.setMediaController(new MediaController(this)); > mVideoView.requestFocus(); > > } > } > } > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy _The Busy Coder's Guide to *Advanced* Android Development_ Version 1.9 Available! -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en