'Android studio, Error: cannot find symbol. I am trying to use an mp4 file to play a video inside my app
I want to have a dedicated button in order to play videos on my page. I have written down the following code. Is it something wrong with it? When I try to build my app in a virtual device, this error shows up:
error: cannot find symbol
String videopath = "android.resource://com.example.royale_assistant/"+R.raw.pekkavid;
^
symbol: variable pekkavid
location: class raw
This is my code at the moment.`
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_3);
clk1 = (Button) findViewById(R.id.button1);
videov1 = (VideoView) findViewById(R.id.videoView1);
imageButton2 = (ImageButton) findViewById(R.id.imageButton2);
imageButton2.setOnClickListener(new View.OnClickListener() {
public void onClick (View v) {
Intent intent = new Intent(Activity3.this,MainActivity.class);
startActivity(intent);
}
});
}
public void videoplay(View b)
{
String videopath = "android.resource://com.example.royale_assistant/"+R.raw.pekkavid;
Uri uri = Uri.parse(videopath);
videov1.setVideoURI(uri);
videov1.start();
}
}`
Thank you in advance for any advice
Solution 1:[1]
Ok just make changes in your videopath file. Add the below code in your videopath file.
String videopath = ""file:///android_res/raw/pekkavid"
// if above code not work, then add .mp4 after your video file as below
String videopath = ""file:///android_res/raw/pekkavid.mp4"
I only suggest you use MediaPlayer to play videos. It is very simple to play videos. If the problem is the same, let me know
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | M Dev |
