Advertisement
P22DX

Hello.java

Dec 18th, 2019
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.82 KB | None | 0 0
  1. package com.hello;
  2. import java.io.Console;
  3. import java.io.File;
  4. import java.io.IOException;
  5. import android.media.MediaPlayer;
  6.  
  7. public class Hello {
  8.  
  9.     public static void audioPlayer(String path, String fileName) throws IOException{
  10.         //set up MediaPlayer    
  11.         MediaPlayer mp = new MediaPlayer();
  12.         mp.setDataSource(path + File.separator + fileName);
  13.         mp.prepare();
  14.         mp.start();
  15.  
  16.     }
  17.     public static void main(String[] args) throws IOException {
  18.         try {
  19.             System.out.print("Name : ");
  20.             Console console = System.console();
  21.             String name = console.readLine();
  22.             System.out.println("Playing > " + name);
  23.             Hello.audioPlayer("assets" + File.separator, name);
  24.         }
  25.         catch (Exception e) {
  26.             e.printStackTrace();
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement