Exemplo n.º 1
0
media media::from_file(class instance &instance, const std::string &path) noexcept
{
#if defined(__unix__) || defined(__APPLE__)
    return libvlc_media_new_path(instance, path.c_str());
#elif defined(WIN32)
    std::string bspath = path;
    std::replace(bspath.begin(), bspath.end(), '/', '\\');
    return libvlc_media_new_path(instance, bspath.c_str());
#endif
}
Exemplo n.º 2
0
void SoundPlay::inputFile(char* input_name) {

	libvlc_instance_t *inst;
	libvlc_media_player_t *mp;
	libvlc_media_t *m;

	// load the vlc engine
	inst = libvlc_new(0, NULL);

	// create a new item
	m = libvlc_media_new_path(inst, input_name);

	// 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(2);

	// stop playing
	libvlc_media_player_stop(mp);

	// free the media_player
	libvlc_media_player_release(mp);

	libvlc_release(inst);
}
Exemplo n.º 3
0
void Player::playFile(QString ofile)
{
    /*the file has to be in one of the following formats /perhaps a little bit outdated)

    [file://]filename              Plain media file
    http://ip:port/file            HTTP URL
    ftp://ip:port/file             FTP URL
    mms://ip:port/file             MMS URL
    screen://                      Screen capture
    [dvd://][device][@raw_device]  DVD device
    [vcd://][device]               VCD device
    [cdda://][device]              Audio CD device
    udp:[[<source address>]@[<bind address>][:<bind port>]]
    */        

    /*Prevent path problems*/
    QString file = ofile.replace('/','\\');

    /* Create a new LibVLC media descriptor */
    media = libvlc_media_new_path(vlcInstance, file.toLatin1());

    libvlc_media_player_set_media (mediaPlayer, media);

    libvlc_media_player_set_xwindow (mediaPlayer, reinterpret_cast<unsigned int>(videoWidget->winId()));

    /* Play */
    libvlc_media_player_play (mediaPlayer);
    isPlaying=true;
}
Exemplo n.º 4
0
void Mwindow::openFile() {

    /* The basic file-select box */
    QString fileOpen = QFileDialog::getOpenFileName(this, tr("Load a file"), "~");

    /* Stop if something is playing */
    if (vlcPlayer && libvlc_media_player_is_playing(vlcPlayer))
        stop();

    /* Create a new Media */
    libvlc_media_t *vlcMedia = libvlc_media_new_path(vlcInstance, qtu(fileOpen));
    if (!vlcMedia)
        return;

    /* Create a new libvlc player */
    vlcPlayer = libvlc_media_player_new_from_media (vlcMedia);

    /* Release the media */
    libvlc_media_release(vlcMedia);

    /* Integrate the video in the interface */
#if defined(Q_OS_MAC)
    libvlc_media_player_set_nsobject(vlcPlayer, (void *)videoWidget->winId());
#elif defined(Q_OS_UNIX)
    libvlc_media_player_set_xwindow(vlcPlayer, videoWidget->winId());
#elif defined(Q_OS_WIN)
    libvlc_media_player_set_hwnd(vlcPlayer, videoWidget->winId());
#endif

    /* And start playback */
    libvlc_media_player_play (vlcPlayer);

    /* Update playback button */
    playBut->setText("Pause");
}
Exemplo n.º 5
0
bool VlcVideoPlayer::loadVideo(const char* path)
{
	if(vlcMedia = libvlc_media_new_path(vlcInstance, path))
	{
        libvlc_media_player_set_media(vlcPlayer, vlcMedia);
        libvlc_media_release(vlcMedia);

        // Needed for mixing VLC and wxWidgets.
        // Needs to be after above calls, or else bug with stop button!
        libvlc_media_player_set_hwnd( vlcPlayer, reinterpret_cast<void *> ( (HWND)this->GetHandle() ) );

		/// @todo ????
        // Stuff
        //libvlc_media_player_next_frame(vlcPlayer);
		//libvlc_video_set_format(vlcPlayer);

        _DEBUG_ DSTREAM << "Loaded video file." << endl;
    }
    else
    {
		_DEBUG_ DSTREAM << "Can't load media from path" << endl;
		wxMessageDialog (this, "Can't load media from path");

        return false;
    }

    return true; // Didn't fails loading.
}
void Player::playFile(QString file)
{
    //the file has to be in one of the following formats /perhaps a little bit outdated)
    /*
    [file://]filename              Plain media file
    http://ip:port/file            HTTP URL
    ftp://ip:port/file             FTP URL
    mms://ip:port/file             MMS URL
    screen://                      Screen capture
    [dvd://][device][@raw_device]  DVD device
    [vcd://][device]               VCD device
    [cdda://][device]              Audio CD device
    udp:[[<source address>]@[<bind address>][:<bind port>]]
    */

    /* Create a new LibVLC media descriptor */
    _m = libvlc_media_new_path(_vlcinstance, file.toAscii());
    //_m = libvlc_media_new (_vlcinstance, file.toAscii(), &_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0.
    //raise(&_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0.

    libvlc_media_player_set_media (_mp, _m);
    //libvlc_media_player_set_media (_mp, _m, &_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0.
    //raise(&_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0.

    // /!\ Please note /!\
    //
    // passing the widget to the lib shows vlc at which position it should show up
    // vlc automatically resizes the video to the given size of the widget
    // and it even resizes it, if the size changes at the playing

    /* Get our media instance to use our window */
    #if defined(Q_OS_WIN)
        libvlc_media_player_set_drawable(_mp, reinterpret_cast<unsigned int>(_videoWidget->winId()));
        //libvlc_media_player_set_drawable(_mp, reinterpret_cast<unsigned int>(_videoWidget->winId()), &_vlcexcep ); // [20101215 JG] Used for versions prior to VLC 1.2.0.
        //libvlc_media_player_set_hwnd(_mp, _videoWidget->winId(), &_vlcexcep ); // for vlc 1.0
    #elif defined(Q_OS_MAC)
        libvlc_media_player_set_drawable(_mp, _videoWidget->winId());
        //libvlc_media_player_set_drawable(_mp, _videoWidget->winId(), &_vlcexcep ); // [20101215 JG] Used for versions prior to VLC 1.2.0.
        //libvlc_media_player_set_agl (_mp, _videoWidget->winId(), &_vlcexcep); // for vlc 1.0
    #else //Linux
        //[20101201 Ondrej Spilka] obsolete call on libVLC >=1.1.5
        //libvlc_media_player_set_drawable(_mp, _videoWidget->winId(), &_vlcexcep );
        //libvlc_media_player_set_xwindow(_mp, _videoWidget->winId(), &_vlcexcep ); // for vlc 1.0

     /* again note X11 handle on Linux is needed
        winID() returns X11 handle when QX11EmbedContainer us used */

        int windid = _videoWidget->winId();
        libvlc_media_player_set_xwindow (_mp, windid );

    #endif
    //raise(&_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0.

    /* Play */
    libvlc_media_player_play (_mp);
    //libvlc_media_player_play (_mp, &_vlcexcep ); // [20101215 JG] Used for versions prior to VLC 1.2.0.
    //raise(&_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0.

    _isPlaying=true;
}
Exemplo n.º 7
0
void VLCMainwindow::openFile() {
    /* Just the basic file-select box */
    QString fileOpen = QFileDialog::getOpenFileName(this,tr("Load a file"), "~");
    fileOpen.replace("/", "\\");
    /* Stop if something is playing */
    if( vlcPlayer && libvlc_media_player_is_playing(vlcPlayer) )
        stop();

    /* New Media */
    libvlc_media_t *vlcMedia = libvlc_media_new_path(vlcObject,qtu(fileOpen));
    if( !vlcMedia )
        return;
    vlcPlayer = libvlc_media_player_new_from_media (vlcMedia);
    libvlc_media_release(vlcMedia);

    /* Integrate the video in the interface */
#if defined(Q_OS_MAC)
    libvlc_media_player_set_nsobject(vlcPlayer, videoWidget->winId());
#elif defined(Q_OS_UNIX)
    libvlc_media_player_set_xwindow(vlcPlayer, videoWidget->winId());
#elif defined(Q_OS_WIN)
    libvlc_media_player_set_hwnd(vlcPlayer, videoWidget->winId());
#endif

    //int windid = videoWidget->winId();
    //libvlc_media_player_set_xwindow (vlcPlayer, windid );

    /* And play */
    libvlc_media_player_play (vlcPlayer);

    //Set vars and text correctly
    playBut->setText("Pause");
}
Exemplo n.º 8
0
void VideoWindow::mediaSelected(QString filename)
{
    // stop any current playback
    stopPlayback();

    // release whatever is already loaded
    if (m) libvlc_media_release(m);
    m = NULL;

    if (filename.endsWith("/DVD") || (filename != "" && QFile(filename).exists())) {

#ifdef Q_OS_LINUX
        QString fileURL = "file://" + filename.replace(" ","%20").replace("\\", "/");
#else
        // A Windows "c:\xyz\abc def.avi" filename should become file:///c:/xyz/abc%20def.avi
        QString fileURL = "file:///" + filename.replace(" ","%20").replace("\\", "/");
#endif
        //qDebug()<<"file url="<<fileURL;

        /* open media */
        m = libvlc_media_new_path(inst, filename.endsWith("/DVD") ? "dvd://" : fileURL.toLatin1());

        /* set the media to playback */
        if (m) libvlc_media_player_set_media (mp, m);

        m_MediaChanged = true;
    }
}
Exemplo n.º 9
0
int libvlc_load(const char *path)
{
  int nameId = lastElem;

  if (g_file_test(path, G_FILE_TEST_EXISTS) == 0) {
    DPRINT_ERR("%s doesn't exist", path);
    goto error;
  }

  soundInst[nameId] = libvlc_new(0, NULL);
  soundMedia[nameId] = libvlc_media_new_path(soundInst[nameId], path);
  soundPlay[nameId] = libvlc_media_player_new_from_media(soundMedia[nameId]);

  if (soundInst[nameId]  == NULL || soundMedia[nameId] == NULL ||
      soundPlay[nameId] == NULL) {
    DPRINT_ERR("fail to load %s", path);
    goto error;
  }

  /* if (loop != 0) { */
  /*   libvlc_media_add_option(media, "input-repeat=-1"); */
  /* } */

  is_used[nameId] = 1;
  ++lastElem;
  return nameId;
 error:
  libvlc_stop(nameId);
  return -1;
}
Exemplo n.º 10
0
void VlcMedia::initMedia(const QString &location,
                         const bool &localFile,
                         VlcInstance *instance)
{
    _currentLocation = location;
    QString l = location;
#if defined(Q_OS_WIN32)
    if (localFile)
        l.replace("/", "\\");
#endif

    // Create a new libvlc media descriptor from location
    if (localFile)
        _vlcMedia = libvlc_media_new_path(instance->core(), l.toLocal8Bit().data());
    else
        _vlcMedia = libvlc_media_new_location(instance->core(), l.toLocal8Bit().data());

    _vlcEvents = libvlc_media_event_manager(_vlcMedia);

    createCoreConnections();

    VlcError::errmsg();

    qDebug() << "libvlc" << "Media:" << location << "Local:" << localFile;
}
Exemplo n.º 11
0
JNIEXPORT void JNICALL NAME(nativeSetDataSource)(JNIEnv *env, jobject thiz, jstring path)
{
    libvlc_instance_t *instance = (libvlc_instance_t *) getIntValue(env, thiz, "mLibVlcInstance");
    libvlc_media_player_t *mp = (libvlc_media_player_t *) getIntValue(env, thiz, "mLibVlcMediaPlayer");
    const char *str = (*env)->GetStringUTFChars(env, path, 0);
    if (!str)
    {
        /* XXX: throw */
        return;
    }
    libvlc_media_t *media = (*str == '/') ? libvlc_media_new_path(instance, str) : libvlc_media_new_location(instance, str);
    if (media)
    {
        libvlc_event_manager_t *em = libvlc_media_event_manager(media);
        for (int i = 0; i < sizeof(md_listening) / sizeof(*md_listening); i++)
        {
            libvlc_event_attach(em, md_listening[i], vlc_event_callback, thiz);
        }
        /* this will cancel current input and start a new one */
        libvlc_media_player_set_media(mp, media);
        setIntValue(env, thiz, "mNativeMediaBufferingCount", 0);
    }
    (*env)->ReleaseStringUTFChars(env, path, str);
    setIntValue(env, thiz, "mLibVlcMedia", (jint) media);
}
Exemplo n.º 12
0
// retorna true si es un video, false en caso contrario
// Si es un video ademas rellena los parametros Tiempo, nAncho y nAlto
const bool InformacionArchivoEx::_AnalisisVLC(const TCHAR *Path, UINT64 &Tiempo, UINT &nAncho, UINT &nAlto, libvlc_instance_t *Instancia) {
	char	Destino[2049];
	size_t  TamnTexto = wcslen(Path);
	int		TamRes = WideCharToMultiByte(CP_UTF8, NULL, Path, TamnTexto, Destino, 2048, NULL, NULL);
	Destino[TamRes] = 0;

	libvlc_media_t			*Media			= NULL;
	libvlc_media_player_t	*nMediaPlayer	= NULL;
	Media = libvlc_media_new_path(Instancia, Destino);

	libvlc_media_parse(Media);
	libvlc_media_add_option(Media, "sout=#description:dummy");

	nMediaPlayer = libvlc_media_player_new_from_media(Media);

	libvlc_state_t Estado = libvlc_Opening;
	libvlc_media_player_play(nMediaPlayer);

    //posible deadlock
	// Esperamos hasta que empieze el play
	while (Estado != libvlc_Playing && Estado != libvlc_Ended) { 
		Estado = libvlc_media_player_get_state(nMediaPlayer);
        Sleep(100);
		if (Estado == libvlc_Error) { // Hay un error en la libvlc, salimos
			Sleep(300); // Nos aseguramos de que el log se escriba
			libvlc_media_player_stop(nMediaPlayer);
			libvlc_media_release(Media);
			libvlc_media_player_release(nMediaPlayer);
			Tiempo = 0;
			nAncho = 0;
			nAlto = 0;
			return false;
		}
	}
	
	// Miramos los streams disponibles y buscamos el de video
	libvlc_media_track_info_t *TI = NULL;
	int z = libvlc_media_get_tracks_info(Media, &TI);
	for (int n = 0; n < z; n++) {
		if (TI->i_type == libvlc_track_video) {
			libvlc_media_player_stop(nMediaPlayer);
			Tiempo = 0; //libvlc_media_player_get_length(nMediaPlayer); // NO DA BIEN EL TIEMPO..............
			nAncho = TI->u.video.i_width;
			nAlto = TI->u.video.i_height;
			libvlc_media_release(Media);
			libvlc_media_player_release(nMediaPlayer);		
			return true;
		}
		TI ++;
	}
	libvlc_media_release(Media);
	libvlc_media_player_release(nMediaPlayer);		

	// No hay streams de video retornamos false
	Tiempo	= 0;
	nAncho	= 0;
	nAlto	= 0;
	return false;
}
Exemplo n.º 13
0
static char *
path_to_mrl(libvlc_instance_t *p_vlc, const char *psz_path)
{
    libvlc_media_t *p_m = libvlc_media_new_path(p_vlc, psz_path);
    char *psz_mrl = libvlc_media_get_mrl(p_m);
    libvlc_media_release(p_m);
    return psz_mrl;
}
Exemplo n.º 14
0
libvlc_media_t *VLC::newMediaFromPath(const char *path) {
    libvlc_media_t *mediaData = libvlc_media_new_path(libvlcInstance, path);
    libvlc_media_parse(mediaData);
    if (!libvlc_media_is_parsed(mediaData) || libvlc_media_get_duration(mediaData) == 0) {
        VLC::release(mediaData);
        return NULL;
    }
    return mediaData;
}
Exemplo n.º 15
0
void Player::setUrl(const QUrl& url)
{
    libvlc_media_t *media = libvlc_media_new_path(vlcInstance(), url.toString().toLocal8Bit().constData());
    m_mediaPlayer.setMedia(media);
    m_mediaPlayer.setFormat("RV32", m_bounds.width(), m_bounds.height(), m_bounds.width() * 4);
    libvlc_media_release(media);

    play();
}
Exemplo n.º 16
0
	void VLCWrapper::addRow (const QString& location)
	{
		libvlc_media_t *m = libvlc_media_new_path (Instance_.get (),
				location.toUtf8 ());

		if (!libvlc_media_list_add_media (List_.get (), m))
			emit itemAdded (GetItemMeta (RowCount () - 1, location), location);
		else
			libvlc_media_release (m);
	}
Exemplo n.º 17
0
 /** File has to be in one of the following formats:
     [file://]filename              Plain media file
     http://ip:port/file            HTTP URL
     ftp://ip:port/file             FTP URL
     mms://ip:port/file             MMS URL
     screen://                      Screen capture
     [dvd://][device][@raw_device]  DVD device
     [vcd://][device]               VCD device
     [cdda://][device]              Audio CD device
     udp:[[<source address>]@[<bind address>][:<bind port>]]
 */
 void open( const std::string& file, bool needPlay=true, unsigned int w=512, unsigned int h=512 )
 {
     _vlcMedia = libvlc_media_new_path( _vlc, file.c_str() );
     libvlc_media_player_set_media( _vlcPlayer, _vlcMedia );
     libvlc_video_set_callbacks( _vlcPlayer, &VLCImageStream::lockFunc, &VLCImageStream::unlockFunc,
                                 &VLCImageStream::displayFunc, this );
     libvlc_video_set_format( _vlcPlayer, "RGBA", w, h, w*4 );
     
     allocateImage( w, h, 1, GL_RGBA, GL_UNSIGNED_BYTE );
     if ( needPlay ) play();
 }
Exemplo n.º 18
0
static bool media_file_dj_play(const char *filename,int * panel, float start,uint8_t end)
{
	hwnd_handle = panel;
	
	media_inst = libvlc_new(0,NULL);
	
	media_handle = libvlc_media_new_path(media_inst,filename);
	mediaplay = libvlc_media_player_new_from_media(media_handle);
	
	
}
Exemplo n.º 19
0
VLCMedia LibVLC::addMedia(const char* path){

  libvlc_media_t *current_media = libvlc_media_new_path(instance, path);

  if(fopen (path,"r") == NULL){
    static VALUE vlcerror = rb_define_class("VLCException", rb_eStandardError);
    rb_raise(vlcerror, "media doesn't exist");

  }
  
  return VLCMedia(instance,current_media);
}
Exemplo n.º 20
0
int main(int argc, const char **argv)
{
    const char *in;
    char *out, *out_with_ext;
    int width;
    pthread_condattr_t attr;
    libvlc_instance_t *libvlc;
    libvlc_media_player_t *mp;
    libvlc_media_t *m;

    /* mandatory to support UTF-8 filenames (provided the locale is well set)*/
    setlocale(LC_ALL, "");

    cmdline(argc, argv, &in, &out, &out_with_ext, &width);

    pthread_condattr_init(&attr);
    pthread_condattr_setclock(&attr, CLOCK_MONOTONIC);
    pthread_cond_init(&wait, &attr);
    pthread_condattr_destroy(&attr);

    /* starts vlc */
    libvlc = create_libvlc();
    assert(libvlc);

    m = libvlc_media_new_path(libvlc, in);
    assert(m);

    mp = libvlc_media_player_new_from_media(m);
    assert(mp);

    libvlc_media_player_play(mp);

    /* takes snapshot */
    set_position(mp);
    snapshot(mp, width, out_with_ext);

    libvlc_media_player_stop(mp);

    /* clean up */
    if (out != out_with_ext) {
        rename(out_with_ext, out);
        free(out_with_ext);
    }
    free(out);

    libvlc_media_player_release(mp);
    libvlc_media_release(m);
    libvlc_release(libvlc);

    pthread_cond_destroy(&wait);

    return 0;
}
Exemplo n.º 21
0
void Audiotheque::GetAllSongsBy(Glib::ustring artist)
{
	std::vector<Gtk::Widget*> children = hbox.get_children();
	for(std::vector<Gtk::Widget*>::iterator it=children.begin()+2; it!=children.end(); it++)
		hbox.remove(**it);
		
	libvlc_instance_t *inst;
	inst = libvlc_new (0, NULL);
	libvlc_media_t *media;

	vbox = Gtk::manage(new Gtk::VBox(false,2));
	vbox->set_size_request(300,0);

	Gtk::Button* button;
	std::string path = dirpath+"/"+artist;
	DIR* rep = opendir(path.c_str());

	button = Gtk::manage(new Gtk::Button("Tous les titres"));
	vbox->pack_start(*button,Gtk::PACK_SHRINK);

	if(rep!=NULL) {
		struct dirent* ent;
		std::string here = ".";
		std::string parent = "..";
		while((ent=readdir(rep))!=NULL) {
			if(here.compare(ent->d_name)!=0 && parent.compare(ent->d_name)!=0) {
				std::string subdirpath = path+"/"+ent->d_name;
				DIR* subdir = opendir(subdirpath.c_str());
				if(subdir!=NULL) {
					struct dirent* subent;
					while((subent=readdir(subdir))!=NULL) {
						if(here.compare(subent->d_name)!=0 && parent.compare(subent->d_name)!=0) {
							std::string songpath = subdirpath+"/";
							songpath += subent->d_name;
							media = libvlc_media_new_path(inst,songpath.c_str());
							libvlc_media_parse(media);
							char* title = libvlc_media_get_meta(media,libvlc_meta_Title);
							button = Gtk::manage(new Gtk::Button(title));
							vbox->pack_start(*button,Gtk::PACK_SHRINK);
						}
					}
					closedir(subdir);
				}
			}
		}
		closedir(rep);
	}	

	hbox.pack_start(*vbox,Gtk::PACK_SHRINK);

	hbox.show_all_children();
}
Exemplo n.º 22
0
Media::Media(const QString &location, libvlc_instance_t *vlcInstance, QObject *parent , bool isFile) :
    QObject(parent),_original(NULL),
    _usageCount(0)
{
    initMedia(location);
    if(isFile)
        _vlcMedia = libvlc_media_new_path(vlcInstance, location.toStdString().data());
    else
        _vlcMedia = libvlc_media_new_location(vlcInstance, location.toStdString().data());

    _instance = vlcInstance;
    parseMediaInfos();
}
Exemplo n.º 23
0
/**
 * @brief Load media with specified filename into player widget
 *
 * It does not start playing until playback is started or toggled.
 * "time-changed" and "length-changed" signals will be emitted immediately
 * after successfully loading the media. The time-adjustment will also be
 * reconfigured appropriately.
 *
 * @param player \e GtkVlcPlayer instance to load file into.
 * @param file   \e Filename to load
 * @return \c TRUE on success, else \c FALSE
 */
gboolean
gtk_vlc_player_load_filename(GtkVlcPlayer *player, const gchar *file)
{
	libvlc_media_t *media;

	media = libvlc_media_new_path(player->priv->vlc_inst,
				      (const char *)file);
	if (media == NULL)
		return FALSE;
	vlc_player_load_media(player, media);
	libvlc_media_release(media);

	return TRUE;
}
Exemplo n.º 24
0
bool CAVPlayer::Play(const std::string &strPath)
{
    if (! m_pVLC_Inst)
    {// 如果播放引擎没有创建,则创建它
        Init();
    }

    if(strPath.empty() || ! m_pVLC_Inst)
    {// 如果链接地址为空,或播放引擎没创建,则直接返回
        return false;
    }

    // 验证地址是网络地址,还是本地地址
    bool bURL = false;
	bURL = IsURL(strPath);

    Stop();

    bool bRet = false;
    libvlc_media_t *m = NULL;

    if (bURL)
    {// 网络路径
        m = libvlc_media_new_location(m_pVLC_Inst, strPath.c_str());
    } 
    else
    {// 本地路径
        m = libvlc_media_new_path(m_pVLC_Inst, strPath.c_str());
    }

    if (m)
    {
        if (m_pVLC_Player = libvlc_media_player_new_from_media(m))
        {
            libvlc_media_player_set_hwnd(m_pVLC_Player, m_hWnd);
            libvlc_media_player_play(m_pVLC_Player);
			m_bStatus = em_play;//播放状态
            // 事件管理
            libvlc_event_manager_t *vlc_evt_man = libvlc_media_player_event_manager(m_pVLC_Player);
            libvlc_event_attach(vlc_evt_man, libvlc_MediaPlayerPlaying,CAVPlayer::OnVLC_Event, this);
            libvlc_event_attach(vlc_evt_man, libvlc_MediaPlayerPositionChanged, CAVPlayer::OnVLC_Event, this);
            libvlc_event_attach(vlc_evt_man, libvlc_MediaPlayerEndReached, CAVPlayer::OnVLC_Event, this);
            bRet = true;
        }

        libvlc_media_release(m);
    }

    return bRet;
}
Exemplo n.º 25
0
void VLCWrapperImpl::OpenMedia(const char* pMediaPathName)
{
	// Load a new item
	pMedia_ = libvlc_media_new_path(pVLCInstance_, pMediaPathName);
	libvlc_media_player_set_media(pMediaPlayer_, pMedia_);

	//////get file information
	//libvlc_media_parse(pMedia_);
	//unsigned w = 0, h = 0;
	//libvlc_video_get_size(pMediaPlayer_, 0, &w, &h);
	//libvlc_meta_t meta;
	//char *s = libvlc_media_get_meta(pMedia_, libvlc_meta_Title);
	////libvlc_media_get_tracks_info(pMedia_, );
}
Exemplo n.º 26
0
libvlc_media_player_t * player::open(string path) {
    //stop();
    inst = libvlc_new(0, NULL); //constructor    
    m = libvlc_media_new_path(inst, path.c_str());
    if (!m) {
        qDebug("error load");
        return NULL;
    }
    // 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);
    return mp;
}
Exemplo n.º 27
0
void VPlayer::setFile(QString _file)
{
	stop();
	file=_file;
	if(m){
		libvlc_media_release(m);
	}
	if(mp){
		libvlc_media_player_release(mp);
	}
	m=libvlc_media_new_path(vlc,file.toUtf8());
	if(m){
		mp=libvlc_media_player_new_from_media(m);
	}
}
Exemplo n.º 28
0
static void
test_media_has_slaves_from_parent(libvlc_instance_t *p_vlc,
                                  libvlc_media_slave_t *p_expected_slaves,
                                  unsigned i_expected_slaves)
{
    libvlc_media_t *p_m = libvlc_media_new_path(p_vlc, SLAVES_DIR);
    assert(p_m != NULL);

    printf("Parse media dir to get subitems\n");
    media_parse_sync(p_m);

    char *psz_main_media_mrl = path_to_mrl(p_vlc, MAIN_MEDIA_PATH);
    assert(psz_main_media_mrl != NULL);
    printf("Main media mrl: '%s'\n", psz_main_media_mrl);

    printf("Fetch main media from subitems\n");
    libvlc_media_list_t *p_ml = libvlc_media_subitems(p_m);
    assert(p_ml != NULL);
    libvlc_media_list_lock(p_ml);
    int i_count = libvlc_media_list_count(p_ml);
    assert(i_count > 0);
    libvlc_media_t *p_subm = NULL;
    for (int i = 0; i < i_count; ++i)
    {
        p_subm = libvlc_media_list_item_at_index(p_ml, i);
        assert(p_subm != NULL);
        char *psz_mrl = libvlc_media_get_mrl(p_subm);
        assert(psz_mrl != NULL);
        if (strcmp(psz_main_media_mrl, psz_mrl) == 0)
        {
            printf("Found main media\n");
            free(psz_mrl);
            break;
        }
        free(psz_mrl);
        libvlc_media_release(p_subm);
        p_subm = NULL;
    }
    free(psz_main_media_mrl);
    libvlc_media_list_unlock(p_ml);
    libvlc_media_list_release(p_ml);

    assert(p_subm != NULL);
    test_expected_slaves(p_subm, p_expected_slaves, i_expected_slaves);
    libvlc_media_release(p_subm);

    libvlc_media_release(p_m);
}
Exemplo n.º 29
0
void MainWindow::OnOpen(wxCommandEvent& event) {
    wxFileDialog openFileDialog(this, wxT("Choose File"));

    if (openFileDialog.ShowModal() == wxID_CANCEL) {
        return;
    }
    else {
        libvlc_media_t *media;
        wxFileName filename = wxFileName::FileName(openFileDialog.GetPath());
        filename.MakeRelativeTo();
        media = libvlc_media_new_path(vlc_inst, filename.GetFullPath().mb_str());
        libvlc_media_player_set_media(media_player, media);
        play();
        libvlc_media_release(media);
    }
}
Exemplo n.º 30
0
static void test_media_subitems(const char** argv, int argc)
{
    const char *subitems_path = SRCDIR"/samples/subitems";

    libvlc_instance_t *vlc = libvlc_new (argc, argv);
    assert (vlc != NULL);
    libvlc_media_t *media;

    log ("Testing media_subitems: path: '%s'\n", subitems_path);
    media = libvlc_media_new_path (vlc, subitems_path);
    assert (media != NULL);
    test_media_subitems_media (media, false);
    libvlc_media_release (media);

    #define NB_LOCATIONS 2
    char *subitems_realpath = realpath (subitems_path, NULL);
    assert (subitems_realpath != NULL);
    const char *schemes[NB_LOCATIONS] = { "file://", "dir://" };
    for (unsigned i = 0; i < NB_LOCATIONS; ++i)
    {
        char *location;
        assert (asprintf (&location, "%s%s", schemes[i], subitems_realpath) != -1);
        log ("Testing media_subitems: location: '%s'\n", location);
        media = libvlc_media_new_location (vlc, location);
        assert (media != NULL);
        test_media_subitems_media (media, false);
        free (location);
        libvlc_media_release (media);
    }
    free (subitems_realpath);

#ifdef HAVE_OPENAT
    /* listing directory via a fd works only if HAVE_OPENAT is defined */
    int fd = open (subitems_path, O_RDONLY);
    log ("Testing media_subitems: fd: '%d'\n", fd);
    assert (fd >= 0);
    media = libvlc_media_new_fd (vlc, fd);
    assert (media != NULL);
    test_media_subitems_media (media, true);
    libvlc_media_release (media);
    close (fd);
#else
#warning not testing subitems list via a fd location
#endif

    libvlc_release (vlc);
}