Libvlc with C++
Posted: 28 Nov 2014 14:16
Hello everyone,
Well, I am very new to this, so pardon me if I am asking some very easy/naive questions...
What I am basically trying to do is to play a video file through the VLC media player from a C++ program that I have written on Visual studio 2010. Once I run the program I want it to display a window that allows me to browse and choose the video I want to play, then the video would play in VLC.
I figured a starting point might be playing the video with VLC from C++ (by giving it the specific URL) first and then try to do the browsing part.
But now I have two questions:
1- Would that browsing part be doable in VLC/Visual studio? Or for VLC to work through C++ you have to provide the URL always in the code?
2- I found a code that should be doing that very simple task (playing the video with VLC from C++ by giving it the specific URL), the code would compile without any errors but when I try to run it, it crashes with the following error:
" Unhandled exception at 0x00905a4d in vlcplayer.exe: 0xC0000005: Access violation reading location 0x00905a4d."
Now this the code I am using:
// vlcplayer.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <vlc/vlc.h>
using namespace std;
int main(int argc, char **argv)
{
libvlc_instance_t *inst;
libvlc_media_player_t *mp;
libvlc_media_t *m;
inst = libvlc_new(0, NULL);
// create a new item
m = libvlc_media_new_path(inst, "Wildlife.wmv");
// create a media play playing environment
mp = libvlc_media_player_new_from_media(m);
// no need to keep the media now
libvlc_media_release(m);
// play the media_player
libvlc_media_player_play(mp);
Sleep(10);
// stop playing
libvlc_media_player_stop(mp);
// free the media_player
libvlc_media_player_release(mp);
libvlc_release(inst);
return 0;
}
After many trials, I think the the problem is with this line :
inst = libvlc_new(0, NULL);
Loading the VLC media player is not working correctly or this statement returns null.
It would also insert a breakpoint at line 555 in file crtexe.c which is:
mainret = main(argc, argv, envp);
P.S: I am using VLC Player version 2.0.6
Would you have any ideas or suggestions about how I can solve that?
I would really appreciate your help...
Thanks.
Best regards,
Maha
Well, I am very new to this, so pardon me if I am asking some very easy/naive questions...
What I am basically trying to do is to play a video file through the VLC media player from a C++ program that I have written on Visual studio 2010. Once I run the program I want it to display a window that allows me to browse and choose the video I want to play, then the video would play in VLC.
I figured a starting point might be playing the video with VLC from C++ (by giving it the specific URL) first and then try to do the browsing part.
But now I have two questions:
1- Would that browsing part be doable in VLC/Visual studio? Or for VLC to work through C++ you have to provide the URL always in the code?
2- I found a code that should be doing that very simple task (playing the video with VLC from C++ by giving it the specific URL), the code would compile without any errors but when I try to run it, it crashes with the following error:
" Unhandled exception at 0x00905a4d in vlcplayer.exe: 0xC0000005: Access violation reading location 0x00905a4d."
Now this the code I am using:
// vlcplayer.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <vlc/vlc.h>
using namespace std;
int main(int argc, char **argv)
{
libvlc_instance_t *inst;
libvlc_media_player_t *mp;
libvlc_media_t *m;
inst = libvlc_new(0, NULL);
// create a new item
m = libvlc_media_new_path(inst, "Wildlife.wmv");
// create a media play playing environment
mp = libvlc_media_player_new_from_media(m);
// no need to keep the media now
libvlc_media_release(m);
// play the media_player
libvlc_media_player_play(mp);
Sleep(10);
// stop playing
libvlc_media_player_stop(mp);
// free the media_player
libvlc_media_player_release(mp);
libvlc_release(inst);
return 0;
}
After many trials, I think the the problem is with this line :
inst = libvlc_new(0, NULL);
Loading the VLC media player is not working correctly or this statement returns null.
It would also insert a breakpoint at line 555 in file crtexe.c which is:
mainret = main(argc, argv, envp);
P.S: I am using VLC Player version 2.0.6
Would you have any ideas or suggestions about how I can solve that?
I would really appreciate your help...
Thanks.
Best regards,
Maha