Code example for FileInputStream

Methods: getFD

0
		MediaPlayer mp = null;
		int resId = getMusicHandle(inPath);
		if (resId < 0) {
			if (inPath.charAt(0) == File.separatorChar) {
				try { 
		        	FileInputStream fis = new FileInputStream(new File(inPath));
			        FileDescriptor fd = fis.getFD();
					mp = new MediaPlayer();
					mp.setDataSource(fd);
					mp.prepare();
		        } catch(FileNotFoundException e) { 
		            System.out.println(e.getMessage());
		            return null; 
		        } catch(IOException e) { 
		            System.out.println(e.getMessage());
		            return null; 
		        } 
		    } else { 
				Uri uri = Uri.parse(inPath);
				mp = MediaPlayer.create(mContext, uri);
		    }