Code example for MediaPlayer

Methods: isLoopingpreparereleasesetDataSourcesetLooping

0
 
    public static boolean isLooping(String filePath) {        
        MediaPlayer mp = null;
         
        try { 
            mp = new MediaPlayer();
            if (mp.isLooping()) {
                Log.v(TAG, "MediaPlayer.isLooping() returned true after ctor");
                return false; 
            } 
            mp.setDataSource(filePath);
            mp.prepare();
 
            mp.setLooping(true);
            if (!mp.isLooping()) {
                Log.v(TAG, "MediaPlayer.isLooping() returned false after setLooping(true)");
                return false; 
            } 
             
            mp.setLooping(false);
            if (mp.isLooping()) {
                Log.v(TAG, "MediaPlayer.isLooping() returned true after setLooping(false)");
                return false; 
            } 
        }catch (Exception e){
            Log.v(TAG, "Exception : " + e.toString());
            return false; 
        } finally { 
            if (mp != null)
                mp.release();
        } 
 
        return true; 
    }