Page 1 of 1

Play Playlist in a loop using vlcj

Posted: 28 Mar 2013 23:00
by Sharvari
I would like to play playlist in a loop using vlcj. For example if in my playlist there are 4 videos,in this case after playlist finished playing all the videos then again It should to play same playlist again. Please kindly guide me :
1)How to implement playlist using vlcj.
2)How to play the same i.e playlist in loop.

I would appreciate if you provide the source code for the same.

Waiting for the answer..
Many Thanks

Re: Play Playlist in a loop using vlcj

Posted: 29 Mar 2013 08:49
by sherington
Well what have you tried so far? There are *many* examples provided with vlcj, and quite decent Javadoc explaining these things aleady.

Waiting for your answer...

Re: Play Playlist in a loop using vlcj

Posted: 30 Mar 2013 12:29
by Sharvari
Thank you so much for your prompt reply.
As you have suggested I have gone through the examples with vlcj.Finally got the solution.

Code: Select all

//Set Videosurface Canvas canvas = new Canvas(); canvas.setBackground(Color.green); CanvasVideoSurface videoSurface = mediaPlayerFactory.newVideoSurface(canvas); EmbeddedMediaPlayer mediaPlayer = mediaPlayerFactory.newEmbeddedMediaPlayer(); mediaPlayer.setVideoSurface(videoSurface); MediaListPlayer mediaListPlayer = mediaPlayerFactory.newMediaListPlayer(); String[] mediapath = new String[2]; mediapath[0] = "C:\\Users\\Public\\Videos\\Sample Videos\\Wildlife.wmv"; mediapath[1] = "C:\\Users\\Public\\Videos\\Sample Videos\\The International.mov"; cnt = 0; while (cnt != mediapath.length) { mediaList.addMedia(mediapath[cnt]); cnt++; } mediaListPlayer.setMediaList(mediaList); mediaListPlayer.setMode(MediaListPlayerMode.LOOP); mediaListPlayer.play(); JPanel cp = new JPanel(); cp.setBackground(Color.black); cp.setLayout(new BorderLayout()); cp.add(canvas, BorderLayout.CENTER); JFrame f = new JFrame("vlcj embedded media list player test"); f.setSize(200, 700); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setVisible(true);
Here , still I am not clear with implementation of setting video surface.Because when I want to set height and width to the video,which is getting played.So hence I am using the setbound proerty Canvas object (e.g. canvas.setBounds(0, 0, 400, 400);) It seems not getting apply.So how to set height and width to video ??? As per above specified code video is getting displayed as per jframe's width. But If I want to set height & width to video irrespective to size of jframe , then how to set ??? Please kindly guide me in this. If I am going somewhere wrong then please let me know .

Many Thanks,

Re: Play Playlist in a loop using vlcj

Posted: 30 Mar 2013 13:06
by sherington

Code: Select all

videoSurface.setSize(dimension); frame.pack();
When you change the size you have to "revalidate" the layout of the parent component - the easiest way to do that is to pack your frame. The TestPlayer example in vlcj does exactly this.