Screen closes while changing videos

For questions and discussion that is NOT (I repeat NOT) specific to a certain Operating System.
bramsey2004
New Cone
New Cone
Posts: 1
Joined: 08 Oct 2008 17:46

Screen closes while changing videos

Postby bramsey2004 » 08 Oct 2008 17:54

I'm trying to write my own playlist editor using a csv file. Currently I can play the different files fine but each time a new window is created to play the next video in the list. I need to be able to keep the current player up and just begining playing the next video in that. Below is my code. I'm very new to this API so I might be missing something very basic.

#include <cstdlib>
#include <iostream>
#include <fstream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <vlc/vlc.h>
#include <vector>

using namespace std;

static void raise(libvlc_exception_t * ex)
{
if (libvlc_exception_raised (ex))
{
fprintf (stderr, "error: %s\n", libvlc_exception_get_message(ex));
exit (-1);
}
}

int main(int argc, char* argv[])
{

const char * const vlc_args[] = {
"-I", "dummy", /* Don't use any interface */
"--ignore-config", /* Don't use VLC's config */
"--fullscreen", /* fullscreen toggle */
"--plugin-path=.\\plugins" };
libvlc_exception_t ex;
libvlc_instance_t * inst;
libvlc_media_player_t *mp;
libvlc_media_t *m;
//int i;
string line;
int exit = 0;
int file_count = 0;
int playlist_pos = 0;
int current_pos = 0;
vector<string> file_location;


ifstream myfile ("Playlist_Test.csv");
if (myfile.is_open())
{
while (! myfile.eof() )
{
getline (myfile,line);
cout << line << endl;
file_location.push_back(line);
file_count++;
}
myfile.close();
}
else cout << "Unable to open file";

libvlc_exception_init (&ex);
/* init vlc modules, should be done only once */
inst = libvlc_new (sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args, &ex);
raise (&ex);

mp =libvlc_media_player_new (inst, &ex);
raise (&ex);

while (exit != 1 && (playlist_pos<(file_count-1)))
{

cout << "Playlist pos = "<<playlist_pos <<"File Count ="<<file_count << endl;



/* Create a new item */
m = libvlc_media_new (inst, file_location.at(playlist_pos).c_str(), &ex);
libvlc_media_player_set_media (mp, m, &ex);
raise (&ex);


/* No need to keep the media now */
libvlc_media_release (m);



/* play the media_player */
libvlc_media_player_play (mp, &ex);

Sleep (2000);
while ( current_pos != libvlc_media_player_get_time (mp, &ex))
{
//cout << "total length ="<<libvlc_media_player_get_length (mp, &ex)<< endl;
//cout << "Current Length ="<<libvlc_media_player_get_time (mp, &ex) << endl;
current_pos = libvlc_media_player_get_time (mp, &ex);
Sleep (500);
}

/* Stop playing */
//libvlc_media_player_stop (mp, &ex);

/* Free the media_player */
//libvlc_media_player_release (mp);

//libvlc_release (inst);
//raise (&ex);
playlist_pos++;
}
return 0;
}

Return to “General VLC media player Troubleshooting”

Who is online

Users browsing this forum: No registered users and 198 guests