Code example for FileInputStream

Methods: close, getFD

0
        mediaPlayer.setOnCompletionListener(playbackCompletionListener);
 
        try { 
            // mediaPlayer seems to like file descriptors a lot more than giving 
            // it a file path 
            FileInputStream file = new FileInputStream(filePath);
            mediaPlayer.setDataSource(file.getFD());
            mediaPlayer.prepare();
            file.close();
        } catch (IllegalArgumentException e) {
            // TODO Auto-generated catch block 
            e.printStackTrace();
        } catch (IllegalStateException e) {
            // TODO Auto-generated catch block 
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block 
            e.printStackTrace();
        } 
 
        isPaused = false;