Reputation: 11
I want to add sound to my Android application using the following piece of code:
mp = MediaPlayer.create(this,R.raw.2lna zaman.mp3);
I have already imported MediaPlayer and declared an object of it m
but the problem is when i
write (R.raw)
then there is no any choice called raw and underlined it by red line
Upvotes: 1
Views: 86
Reputation: 4387
In name of audio there is space. Space is not allowed in name. Delete space.
And name also not start with digit so change it too. Rename file so that its start with alphabet.
Also no need of extension i.e .mp3
. For example mp = MediaPlayer.create(this, R.raw.test);
after file name no need to write .mp3
Upvotes: 3
Reputation: 5145
Space is not allowed in name which we add in drawable try to remove space and try again later
mp = MediaPlayer.create(this,R.raw.lna_zaman.mp3);
u can add " _ " instead of space
Upvotes: 0