2 Replies - 865 Views - Last Post: 08 February 2012 - 04:29 PM

Topic Sponsor:

#1 slehmann101  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 46
  • Joined: 30-November 11

Cannot play video

Posted 07 February 2012 - 06:15 PM

Whenever i try to play a video i get the error in the emulator
Cannot play video
Sorry this video cannot be played

here is my java file
 public void onCreate(Bundle savedInstanceState) {
	        super.onCreate(savedInstanceState);
	       playvideo();
	 }
	 
	 public void playvideo() {
		 setContentView(R.layout.mainmenu);
		  


		        VideoView videoView = (VideoView)findViewById(R.id.VideoView);
		        //MediaController mediaController = new MediaController(this);
		        // mediaController.setAnchorView(videoView);
		        //videoView.setMediaController(mediaController);

		        videoView.setVideoPath("R.raw.pizzatycoonmainmenu");

		        videoView.start();  
		    
		}

and here is my XML file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 
   android:id="@+id/LinearLayout01"
   android:layout_height="fill_parent"     
   android:paddingLeft="2px"
   android:paddingRight="2px"
   xmlns:android="http://schemas.android.com/apk/res/android"
   android:paddingTop="2px"
   android:paddingBottom="2px"
   android:layout_width="fill_parent"
   android:orientation="vertical">

      <VideoView 
         android:layout_height="fill_parent"
         android:layout_width="fill_parent" 
         android:id="@+id/VideoView" />
       
      

</LinearLayout>

can anyone please tell me how to correct this

Is This A Good Question/Topic? 0
  • +

Replies To: Cannot play video

#2 H3R3T1C  Icon User is online

  • Android Expert
  • member icon

Reputation: 233
  • View blog
  • Posts: 657
  • Joined: 30-March 07

Re: Cannot play video

Posted 07 February 2012 - 06:37 PM

"R.raw.pizzatycoonmainmenu" is not a path! You need to make a uri for the video source like so:
Uri video = Uri.parse("android.resource://" + getPackageName() + "/" 
+ R.raw.pizzatycoonmainmenu);
videoView.setVideoURI(video);


Was This Post Helpful? 0
  • +
  • -

#3 slehmann101  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 46
  • Joined: 30-November 11

Re: Cannot play video

Posted 08 February 2012 - 04:29 PM

View PostH3R3T1C, on 07 February 2012 - 06:37 PM, said:

"R.raw.pizzatycoonmainmenu" is not a path! You need to make a uri for the video source like so:
Uri video = Uri.parse("android.resource://" + getPackageName() + "/" 
+ R.raw.pizzatycoonmainmenu);
videoView.setVideoURI(video);


That got rid of the error but now in the emulator it just shows a black screen.
I get this error in the logcat:02-08 16:27:37.257: E/InputDispatcher(84): Received spurious receive callback for unknown input channel. fd=205, events=0x8
02-08 16:27:37.266: E/InputDispatcher(84): channel '415fbcc8 com.dev.slehmann/com.dev.slehmann.Menus (server)' ~ Channel is unrecoverably broken and will be disposed!
02-08 16:27:51.396: E/SurfaceFlinger(33): GraphicBufferAlloc::createGraphicBuffer(w=352, h=288) failed (Invalid argument), handle=0x0
02-08 16:27:51.396: E/SurfaceTexture(33): [SurfaceView] dequeueBuffer: SurfaceComposer::createGraphicBuffer failed



this is what my java looks like now
 public  void playvideo() {
		 setContentView(R.layout.mainmenu);
		 
		 VideoView videoView = (VideoView)findViewById(R.id.videoView);
		 Uri video = Uri.parse("android.resource://" + getPackageName() + "/" 
					+ R.raw.pizzatycoonmainmenu);
					videoView.setVideoURI(video);
					 videoView.start();  

		        //MediaController mediaController = new MediaController(this);
		        // mediaController.setAnchorView(videoView);
		        //videoView.setMediaController(mediaController);
		      //videoView.setVideoPath("R.raw.pizzatycoonmainmenu"); 
					 

		       
		    
		}

What have I done wrong?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1