Search code examples
androidandroid-mediaplayer

How to use FFmpegMediaPlayer ? (Windows|Android Studio)


I tried to use the lib prebuilt, but couldn't, I got error on - FFmpegMediaPlayer mp = new FFmpegMediaPlayer();

OR can somebody to recommend good Android MediaPlayer(minSdkVersion >=9) library for playing stream audio?


Solution

  • GIT URL for FFmpegMediaPlayer

    have sample code :

        FFmpegMediaPlayer mp = new FFmpegMediaPlayer();
    mp.setOnPreparedListener(new FFmpegMediaPlayer.OnPreparedListener() {
    
        @Override
        public void onPrepared(FFmpegMediaPlayer mp) {
            mp.start();         
        }
    });
    mp.setOnErrorListener(new FFmpegMediaPlayer.OnErrorListener() {
    
        @Override
        public boolean onError(FFmpegMediaPlayer mp, int what, int extra) {
            mp.release();
            return false;
        }
    });
    
    try {
        mp.setDataSource("<some path or URL>");
        mp.prepareAsync();
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (SecurityException e) {
        e.printStackTrace();
    } catch (IllegalStateException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }