user3508462
user3508462

Reputation: 11

Add a sound to android application

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

Answers (2)

Kanwaljit Singh
Kanwaljit Singh

Reputation: 4387

  1. In name of audio there is space. Space is not allowed in name. Delete space.

  2. And name also not start with digit so change it too. Rename file so that its start with alphabet.

  3. 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

Bhanu Sharma
Bhanu Sharma

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

Related Questions