Using MediaPlayer and sound assets
in
Android Processing
•
10 months ago
okay I currently have a little diddy that goes a bit like this:
- MediaPlayer mediaPlayer = new MediaPlayer();
- assetManager = this.getAssets();
- public void buildMediaPlayer()
- {
- try {
- AssetFileDescriptor fd = assetManager.openFd("songTitle.ogg");
- mediaPlayer.setDataSource(fd.getFileDescriptor(), fd.getStartOffset(), fd.getLength());
- mediaPlayer.prepare();
- }
- catch (IOException e) {
- print("OOOOPPPPPPPPPPPPPPPPPPPSSSSSSSSSSSSSSSS");
- e.printStackTrace();
- }
- }
interestingly it doesnt pint OOOOPPPPPSSS in the terminal, and my song file is right there in the data folder waiting to get copied over to /assets.
So ive read up a bit on alternate ways to declare the datasource using files stored in res/raw, but i dont know enough to figure out how to set that up easily.
anyone got any ideas?
1