Play Playlist in a loop using vlcj

This forum is about all development around libVLC.
Sharvari
New Cone
New Cone
Posts: 6
Joined: 28 Mar 2013 22:27

Play Playlist in a loop using vlcj

Postby Sharvari » 28 Mar 2013 23:00

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

sherington
Cone that earned his stripes
Cone that earned his stripes
Posts: 491
Joined: 10 Sep 2008 11:57
VLC version: master
Operating System: Linux

Re: Play Playlist in a loop using vlcj

Postby sherington » 29 Mar 2013 08:49

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...

Sharvari
New Cone
New Cone
Posts: 6
Joined: 28 Mar 2013 22:27

Re: Play Playlist in a loop using vlcj

Postby Sharvari » 30 Mar 2013 12:29

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,

sherington
Cone that earned his stripes
Cone that earned his stripes
Posts: 491
Joined: 10 Sep 2008 11:57
VLC version: master
Operating System: Linux

Re: Play Playlist in a loop using vlcj

Postby sherington » 30 Mar 2013 13:06

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.


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 25 guests