Reputation: 223
I read the Hello Android book. The app should play a video. I copied the video into res/raw. The App does not run. Why?
I get the following error:
video cannot be resolved or is not a field
Video.java
package org.example.video;
import android.app.Activity;
import android.os.Bundle;
import android.widget.VideoView;
public class Video extends Activity{
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
VideoView video=(VideoView)findViewById(R.id.video);
video.setVideoPath("/raw/VID_20120604_142208.mp4");
video.start();
}
}
Activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<VideoView
android:id="@+id/video"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="center"/>
</FrameLayout>
Cheers.
Upvotes: 0
Views: 1434
Reputation: 11
Use repair video tool to fix your video file, first download the trial version and check if all your files are displayed. If you are satisfied with the demo version then you can switch to full version to recover them. It is one of the finest software to fix error of video file on Mac operating system. Hope this software helps you to sort out your problem. From here you can download the software.
Upvotes: 1
Reputation: 2846
Ran your code with a little modification runs fine
VideoView video=(VideoView)findViewById(R.id.video);
video.setVideoPath("android.resource://org.example.video/raw/learning");
video.start();
Do not add the extension of file
Upvotes: 0