javaaudio-playervlcj

Vlcj audio only player


I am creating a chat application where the user can send audio and video files.

For my video files I have successfully created an embedded video player in my app which will play any video.

But for my audio files I don't want to use an embedded video player with options vout=dummy instead I want to be optimized and use an DirectAudioPlayer for my purposes. I took a look at the MediaFactory create but i don't understand how am I suppose to retrieve these parameters for an specific file.

What I want is just one direct audio player in my application which I can reuse for multiple audio files or is this not possible?


Solution

  • You can use a HeadlessMediaPlayer.

    This is basically the same as the EmbeddedMediaPlayer that you're already using, but with no API to do with displaying the video.

    A word of caution though if you play a video through the HeadlessMediaPlayer, rather than just an audio file, LibVLC will open a native window and play the video - you can suppress this by passing "--no-video" via the MediaPlayerFactory.

    The DirectAudioPlayer is used when you want to access the audio buffer in your application - i.e. "direct" access to the native audio buffer. You would then have to use JavaSound or something to actually play the audio. So I don't think this is what you want.