repeat playing MMS streams

This forum is about all development around libVLC.
geostein8888
Cone that earned his stripes
Cone that earned his stripes
Posts: 142
Joined: 15 Dec 2010 11:32

repeat playing MMS streams

Postby geostein8888 » 15 Jan 2011 15:06

Hellom,#i try to repeat a stream i receive from a MMS Stream server. i'll have to do this, because the stream stops after each title and vlc will not play the next one, but when i activate under the VLC windows player the repeat function VLC reconnects automic again to this server and start playing the next show

the problem i have here is, when i add the option --repeat or --loop to my player under Java, it will not repeat (reconnect) to this server and play thr next coming stream.

with regards

Georg

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: repeat playing MMS streams

Postby sherington » 15 Jan 2011 17:06

Hellom,#i try to repeat a stream i receive from a MMS Stream server. i'll have to do this, because the stream stops after each title and vlc will not play the next one, but when i activate under the VLC windows player the repeat function VLC reconnects automic again to this server and start playing the next show

the problem i have here is, when i add the option --repeat or --loop to my player under Java, it will not repeat (reconnect) to this server and play thr next coming stream.

with regards

Georg
So if you wait for the finished event then call play again, that is not good enough?

geostein8888
Cone that earned his stripes
Cone that earned his stripes
Posts: 142
Joined: 15 Dec 2010 11:32

Re: repeat playing MMS streams

Postby geostein8888 » 15 Jan 2011 17:13

Hello,
thanks for this answer, but when i call play again it takes also again 5-10 sec. to reconnect to the stream, this is a solution i only want to use, when there is no other way.

Georg

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: repeat playing MMS streams

Postby sherington » 16 Jan 2011 09:59

You say Java, presumably you are using the vlcj bindings?

If so, please try vlcj-1.1.5.1 and see the media list player "TestMediaListPlayer.java" in the source code to see how it works.

Please feedback whether this solves your problem or not. If it does, I'll make a new formal release of the bindings. If it doesn't, I'm afraid I have no other idea for you.
Last edited by sherington on 17 Jan 2011 17:25, edited 1 time in total.

geostein8888
Cone that earned his stripes
Cone that earned his stripes
Posts: 142
Joined: 15 Dec 2010 11:32

Re: repeat playing MMS streams

Postby geostein8888 » 16 Jan 2011 17:36

Hello,
thanks for the patch, this works well. The only mystery thing here is, that i'm not able to play the video in my frame, it comes everytime in a extra window as direct 3d output.
i did evrerything as i did it before the playerlist functions and the videosurface is added to my frame and set as videosurface for the embedded mediaplayer.

is there a new feature in this version i have to thinlk about?

with regards
Georg

snapshot of the code (i also changed the code of the sample payer with the contro buttons, and here also a extra window with only the video content comes up):
videoSurface.setBackground(Color.black);

this.videoSurfaceDefDimensions = msmProps.getVideoDimensions();
this.videoSurfaceDimensions = this.videoSurfaceDefDimensions;


// Since we're mixing lightweight Swing components and heavyweight AWT
// components this is probably a good idea

MsmPlayerMouseListener mouseListener = new MsmPlayerMouseListener();

videoSurface.addMouseListener(mouseListener);
videoSurface.addMouseMotionListener(mouseListener);
videoSurface.addMouseWheelListener(mouseListener);
videoSurface.addKeyListener(new MsmPlayerKeyListener());

JPopupMenu.setDefaultLightWeightPopupEnabled(false);

List<String> vlcArgs = new ArrayList<String>();

vlcArgs.add("-vv");
vlcArgs.add("--no-plugins-cache");
if (RuntimeUtil.isWindows()) {
vlcArgs.add("--plugin-path=" + WindowsRuntimeUtil.getVlcInstallDir() + "\\plugins");
}
vlcArgs.add("--sout-keep");

Logger.debug("vlcArgs={}", vlcArgs);

mainFrame = new JFrame("VLC Player 1.1.5 V");

mainFrame.setLayout(new BorderLayout());
mainFrame.setBackground(Color.black);

mainFrame.add(videoSurface, BorderLayout.CENTER);

mediaPlayerFactory = new MediaPlayerFactory(vlcArgs.toArray(new String[vlcArgs.size()]));//, LibVlc.INSTANCE
mediaPlayerFactory.setLogLevel(LogLevel.DBG);

mediaListPlayer = mediaPlayerFactory.newMediaListPlayer();
mediaListPlayer.addMediaListPlayerEventListener(new MediaListPlayerEventListener() {
@Override
public void nextItem(MediaListPlayer mediaListPlayer) {
System.out.println("nextItem()");
}
});

mediaList = mediaPlayerFactory.newMediaList();

mediaPlayer = mediaPlayerFactory.newMediaPlayer(null);
mediaPlayer.setVideoSurface(videoSurface);
mediaListPlayer.setMediaPlayer(mediaPlayer);

mediaPlayer.setPlaySubItems(true);

// Create a new log handler to display the native libvlc log
log = mediaPlayerFactory.newLog();
log.setThreshold(LogLevel.DBG);
logHandler = new LogHandler(log, 1000) // Add a log message handler to send the native log messages to the local log
.addLogMessageHandler(new DefaultLogMessageHandler()) // Add a log message handler to search for media opening error messages in the native log
.addLogMessageHandler(new MatcherLogMessageHandler("^VLC kann die MRL '(.+?)'.*$", new MatcherCallback() {

@Override
public void matched(Matcher matcher) {
Logger.error("failed to open filename {}", matcher.group(1));
System.out.println("GET NET");
}
}));
logHandler.start();


List<AudioOutput> audioOutputs = mediaPlayerFactory.getAudioOutputs();
Logger.debug("audioOutputs={}", audioOutputs);


mediaPlayer.setEnableKeyInputHandling(false);
mediaPlayer.setEnableMouseInputHandling(false);

this.controlsPanel = new PlayerControlsPanel(mediaPlayer, this, msmProps);
mainFrame.add(controlsPanel, BorderLayout.SOUTH);

mainFrame.pack();

here a part of the logg:
[1cae3b74] avcodec decoder warning: Physical channel configuration not set : guessing
[1c9d22cc] main input debug: no usable vout present, spawning one
[1cb7e0dc] main spu text debug: looking for text renderer module: 4 candidates
[1cb7e0dc] freetype spu text debug: Building font databases.
[1c9d22cc] main input debug: Buffering 33%
[1c9d22cc] main input debug: Buffering 33%
[1c9d22cc] main input debug: Buffering 3%
[1c9d22cc] main input debug: Buffering 34%
[1cb7e0dc] freetype spu text debug: Took 22894 microseconds
[1cb7e0dc] freetype spu text debug: Using Arial as font from file C:/Windows/fonts/arial.ttf
[1c9d22cc] main input debug: Buffering 3%
[1c9d22cc] main input debug: control type=1
[1cb7e0dc] freetype spu text debug: using fontsize: 2
[1cb7e0dc] main spu text debug: using text renderer module "freetype"
[1cb7e0dc] main spu text debug: TIMER module_need() : 53.445 ms - Total 53.445 ms / 1 intvls (Avg 53.445 ms)
[1f2cb5bc] main scale debug: looking for video filter2 module: 36 candidates
[1f2cb5bc] swscale scale debug: 32x32 chroma: YUVA -> 16x16 chroma: YUVA with scaling using Bicubic (good quality)
[1f2cb5bc] main scale debug: using video filter2 module "swscale"
[1f2cb5bc] main scale debug: TIMER module_need() : 6.844 ms - Total 6.844 ms / 1 intvls (Avg 6.844 ms)
[1f28195c] main scale debug: looking for video filter2 module: 36 candidates
[1f28195c] yuvp scale debug: YUVP to YUVA converter
[1f28195c] main scale debug: using video filter2 module "yuvp"
[1f28195c] main scale debug: TIMER module_need() : 0.411 ms - Total 0.411 ms / 1 intvls (Avg 0.411 ms)
[1f27cf64] main video output debug: window size: 640x360
[1f27cf64] main video output debug: Deinterlacing available
[1f27cf64] main video output debug: deinterlace 0, mode blend, is_needed 0
[1f27cf64] main video output debug: looking for video output module: 2 candidates
[1f27cf64] vout_wrapper video output debug: Opening vout display wrapper
[0003f0f4] main generic debug: looking for vout display module: 16 candidates
[0003f0f4] direct3d generic debug: creating Vout EventThread
[0003f0f4] direct3d generic debug: DirectXCreateWindow
[199175d4] main window debug: looking for vout window hwnd module: 6 candidates
[199175d4] qt4 window debug: Qt4 interface not found
[199175d4] qt4 window debug: Qt4 interface not found
[199175d4] main window debug: no vout window hwnd module matching "any" could be loaded
[199175d4] main window debug: TIMER module_need() : 0.399 ms - Total 0.399 ms / 1 intvls (Avg 0.399 ms)
[0003f0f4] direct3d generic debug: created video sub-window
[0003f0f4] direct3d generic debug: Vout EventThread running
[0003f0f4] direct3d generic debug: disabling screen saver
[0003f0f4] direct3d generic warning: trying surface pixel format: YV12
[0003f0f4] direct3d generic debug: selected surface pixel format is YV12
[0003f0f4] direct3d generic debug: Direct3D scene created successfully
[0003f0f4] direct3d generic debug: Direct3D device adapter successfully initialized
[0003f0f4] main generic debug: using vout display module "direct3d"
[0003f0f4] main generic debug: TIMER module_need() : 105.832 ms - Total 105.832 ms / 1 intvls (Avg 105.832 ms)
[1f27cf64] main video output debug: using video output module "vout_wrapper"
[1f27cf64] main video output debug: TIMER module_need() : 106.323 ms - Total 106.323 ms / 1 intvls (Avg 106.323 ms)
[1f27cf64] main video output debug: got 1 direct buffer(s)
[1f27cf64] main video output debug: pic render sz 640x360, of (0,0), vsz 640x360, 4cc I420, sar 1:1, msk r0x0 g0x0 b0x0
[1f27cf64] main video output debug: pic in sz 640x360, of (0,0), vsz 640x360, 4cc I420, sar 1:1, msk r0x0 g0x0 b0x0
[1f27cf64] main video output debug: pic out sz 640x360, of (0,0), vsz 640x360, 4cc I420, sar 1:1, msk r0x0 g0x0 b0x0
[1f27cf64] main video output debug: direct render, mapping render pictures 0-23 to system pictures 1-24
[1c9d22cc] main input debug: creating aout

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: repeat playing MMS streams

Postby sherington » 16 Jan 2011 18:17

I already posted a working example. Your code misses a key step from the working example. I event went to the trouble of adding a comment to the example code to address exactly the problem you describe so you should not have missed it.

geostein8888
Cone that earned his stripes
Cone that earned his stripes
Posts: 142
Joined: 15 Dec 2010 11:32

Re: repeat playing MMS streams

Postby geostein8888 » 16 Jan 2011 21:30

Hello,
ok now it works in my application
i dont know why but i readded now the mediaplayer.play()

Georg

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: repeat playing MMS streams

Postby sherington » 17 Jan 2011 09:30

i dont know why but i readded now the mediaplayer.play()
That mediaPlayer.play() is what causes the video surface Canvas to be associated with the native media player instance.

That is not ideal from an API point of view, but it's only needed because of how media list player was integrated. I will try and remove this requirement in a future version.

alexzmrr
New Cone
New Cone
Posts: 5
Joined: 02 Jan 2013 22:33

Re: repeat playing MMS streams

Postby alexzmrr » 02 Jan 2013 22:51

Hello fellows,
Sorry to rise this posts again, but I need help. I have the same problem of the "geostein8888" about the "...a extra window as direct 3d output." in the 5º reply.
And I did not found the working example that the sherington talk about. Please help me. I realy dont know what else to do.
Thank you.

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: repeat playing MMS streams

Postby Jean-Baptiste Kempf » 03 Jan 2013 02:08

Hello fellows,
Sorry to rise this posts again, but I need help. I have the same problem of the "geostein8888" about the "...a extra window as direct 3d output." in the 5º reply.
And I did not found the working example that the sherington talk about. Please help me. I realy dont know what else to do.
Thank you.
Did you set the windows drawable in the code?
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

alexzmrr
New Cone
New Cone
Posts: 5
Joined: 02 Jan 2013 22:33

Re: repeat playing MMS streams

Postby alexzmrr » 03 Jan 2013 17:59

Hello fellows,
Sorry to rise this posts again, but I need help. I have the same problem of the "geostein8888" about the "...a extra window as direct 3d output." in the 5º reply.
And I did not found the working example that the sherington talk about. Please help me. I realy dont know what else to do.
Thank you.
Did you set the windows drawable in the code?
You are talking of this parameter ?!
"Embedded window video
--drawable-hwnd=<integer [-2147483648 .. 2147483647]>
Window handle (HWND)
Video will be embedded in this pre-existing window. If zero, a new
window will be created."

If you do, show me how to use it, because I've tried in so many ways but it fail in an error. Those errors always begin with the message below:
"vlc: unknown option or missing mandatory argument `--drawable-hwnd'
Try `vlc --help' for more information."

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: repeat playing MMS streams

Postby Jean-Baptiste Kempf » 04 Jan 2013 15:11

libvlc_media_player_set_hwnd
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

alexzmrr
New Cone
New Cone
Posts: 5
Joined: 02 Jan 2013 22:33

Re: repeat playing MMS streams

Postby alexzmrr » 04 Jan 2013 17:36

libvlc_media_player_set_hwnd
By definition:
"libvlc_media_player_set_hwnd(p_mi, drawable) ;

Set a Win32/Win64 API window handle (HWND) where the media player should render its video output. If LibVLC was built without Win32/Win64 API output support, then this has no effects.
Parameters:
p_mi - the Media Player.
drawable - windows handle of the drawable." (didnt get it)

Here is my code:
import com.sun.jna.NativeLibrary;
import java.awt.BorderLayout;
import java.awt.Canvas;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Toolkit;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
import pkgFilme.Filme;
import uk.co.caprica.vlcj.player.MediaPlayerFactory;
import uk.co.caprica.vlcj.player.embedded.DefaultFullScreenStrategy;
import uk.co.caprica.vlcj.player.embedded.EmbeddedMediaPlayer;
import uk.co.caprica.vlcj.player.embedded.FullScreenStrategy;
import uk.co.caprica.vlcj.player.list.MediaList;
import uk.co.caprica.vlcj.player.list.MediaListPlayer;
import uk.co.caprica.vlcj.player.list.MediaListPlayerMode;
import uk.co.caprica.vlcj.runtime.RuntimeUtil;
import uk.co.caprica.vlcj.runtime.windows.WindowsRuntimeUtil;

public class MinimalTestPlayer {
public static long cont = 0;
public static MediaList mediaList = null;
public static MediaListPlayer mediaListPlayer = null;

public MinimalTestPlayer() {
registerLibrary();
}

public EmbeddedMediaPlayer play() {
final Canvas videoSurface = new Canvas();
final Frame frame = buildFrame(videoSurface);
final List<String> vlcArgs = new ArrayList<String>();

configureParameters(vlcArgs);

final EmbeddedMediaPlayer mediaPlayer = createPlayer(vlcArgs, videoSurface);
return mediaPlayer;
}

private void registerLibrary() {
NativeLibrary.addSearchPath("libvlc", "C:\\Program Files (x86)\\vlc-1.1.11");
}

private Frame buildFrame(final Canvas videoSurface) {
final Frame f = new Frame("Test Player");
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
f.setBounds(0, 0, screenSize.width, screenSize.height);
f.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
f.setLayout(new BorderLayout());
f.add(videoSurface, BorderLayout.CENTER);
//f.setVisible(true);
f.setUndecorated(true);
return f;
}

private void configureParameters(final List<String> vlcArgs) {
vlcArgs.add("--no-plugins-cache");
vlcArgs.add("--no-video-title-show");
vlcArgs.add("--no-snapshot-preview");
vlcArgs.add("--autoscale");
vlcArgs.add("--fullscreen");

if (RuntimeUtil.isWindows()) {
vlcArgs.add("--plugin-path=" + WindowsRuntimeUtil.getVlcInstallDir() + "\\plugins");
}
}

private EmbeddedMediaPlayer createPlayer(final List<String> vlcArgs, final Canvas videoSurface) {
final MediaPlayerFactory factory = new MediaPlayerFactory(vlcArgs.toArray(new String[vlcArgs.size()]));
FullScreenStrategy fullScreenStrategy = new DefaultFullScreenStrategy(buildFrame(videoSurface));
EmbeddedMediaPlayer mediaPlayer = factory.newMediaPlayer(fullScreenStrategy);

mediaListPlayer = factory.newMediaListPlayer();

mediaPlayer.setVideoSurface(videoSurface);
mediaPlayer.setFullScreen(true);
mediaList = factory.newMediaList();
return mediaPlayer;
}

public static void main(String[] args) throws InterruptedException, FileNotFoundException, Throwable {
MinimalTestPlayer player = new MinimalTestPlayer();
EmbeddedMediaPlayer mpyer = player.play();
Filme filme = new Filme();
for(int i=0; i < 3;i++) {
mediaList.addMedia(filme.getNextFilme());
}
mediaListPlayer.setMediaList(mediaList);
mediaListPlayer.setMediaPlayer(mpyer);
mediaListPlayer.setMode(MediaListPlayerMode.LOOP);
mediaListPlayer.play();

Thread.currentThread().join();
}
}


How can I use the libvlc_media_player_set_hwnd(p_mi, drawable) ; in my code ? some one can help me ?! :oops:

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: repeat playing MMS streams

Postby sherington » 04 Jan 2013 18:22

Please format your posted code with the right "code" tags so it's easier to read!

Anyway...

The libvlc_media_player_set_hwnd() call is encapsulated for you inside the media player implementation, so really you should forget about that.

You seem to be using vlc 1.1.11 and an old version of vlcj. I would really recommend you upgrade to vlc 2.0.x and vlcj 2.1.0. I took your test class, made the changes required to make it work with vlcj 2.1.0, and it does in fact work properly for me.

But, if you must use the older versions, have a look at this test class:
http://code.google.com/p/vlcj/source/br ... layer.java

Here is a part of that test class:

Code: Select all

// Create an media player to play the items in the play-list EmbeddedMediaPlayer mediaPlayer = mediaPlayerFactory.newMediaPlayer(null); mediaPlayer.setVideoSurface(videoSurface); // Attach the media player to the media list player mediaListPlayer.setMediaPlayer(mediaPlayer); // Unfortunately we have to invoke play() here to ensure the video surface <---- THIS IS WHAT I THINK CAUSES YOUR ISSUE! // gets set - this will NOT actually start playing anything (this API might // change) mediaPlayer.play(); // Now start playing the play-list - this will cause the associated media // player instance to start mediaListPlayer.play();
If you note the comments above, you should invoke mediaPlayer.play() before you invoke mediaListPlayer.play(). Your code does not do this from what I could see. If you do not do this, then the Canvas you created for the video surface is never associated with the native media player, so vlc creates it's own window for the video instead.

This was a design flaw in vlcj which was fixed in later versions of vlcj.

In short, with the version of vlcj that you are using, you must invoke mediaPlayer.play() once to associate the Canvas video surface with the media player before you invoke mediaListPlayer.play()

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: repeat playing MMS streams

Postby sherington » 04 Jan 2013 18:35

If you can upgrade to a newer version of vlcj, this example shows how much easier it now is to create a media list player:

https://github.com/caprica/vlcj/blob/ma ... tTest.java

alexzmrr
New Cone
New Cone
Posts: 5
Joined: 02 Jan 2013 22:33

Re: repeat playing MMS streams

Postby alexzmrr » 24 Feb 2013 17:52

Hello again. First, I must apologise for revive this topic so long time after the last answer :oops: . But I was without internet access, and when it returns I forgot my password and so on...
I'm not here to only apologise, but to say thank you for all :wink: ...aaaand to make another hot question!
How can I play more than 1 video at the same time in the same frame window, keeping the aspect of a fullscreen presentation ??? :?: :mrgreen: :?:


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 3 guests