Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.hello;
- import java.io.Console;
- import java.io.File;
- import java.io.IOException;
- import android.media.MediaPlayer;
- public class Hello {
- public static void audioPlayer(String path, String fileName) throws IOException{
- //set up MediaPlayer
- MediaPlayer mp = new MediaPlayer();
- mp.setDataSource(path + File.separator + fileName);
- mp.prepare();
- mp.start();
- }
- public static void main(String[] args) throws IOException {
- try {
- System.out.print("Name : ");
- Console console = System.console();
- String name = console.readLine();
- System.out.println("Playing > " + name);
- Hello.audioPlayer("assets" + File.separator, name);
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement