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;
}
예제 #2
0
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 */
              "--plugin-path=/set/your/path/to/libvlc/module/if/you/are/on/windows/or/macosx" };
    libvlc_exception_t ex;
    libvlc_instance_t * inst;
    libvlc_media_player_t *mp;
    libvlc_media_t *m;
    
    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);
 
    /* Create a new item */
    m = libvlc_media_new (inst, "http://mycool.movie.com/test.mov", &ex);
    raise (&ex);
   
    /* XXX: demo art and meta information fetching */
   
    /* Create a media player playing environement */
    mp = libvlc_media_player_new_from_media (m, &ex);
    raise (&ex);
    
    /* No need to keep the media now */
    libvlc_media_release (m);

#if 0
    /* This is a non working code that show how to hooks into a window,
     * if we have a window around */
     libvlc_drawable_t drawable = xdrawable;
    /* or on windows */
     libvlc_drawable_t drawable = hwnd;

     libvlc_media_player_set_drawable (mp, drawable, &ex);
     raise (&ex);
#endif

    /* play the media_player */
    libvlc_media_player_play (mp, &ex);
    raise (&ex);
   
    sleep (10); /* Let it play a bit */
   
    /* Stop playing */
#warning There is known deadlock bug here. Please update to LibVLC 1.1!
    libvlc_media_player_stop (mp, &ex);

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

    libvlc_release (inst);
    raise (&ex);

    return 0;
}
예제 #3
0
파일: video.c 프로젝트: mahaserver/MHSVLC
/* Deprecated use libvlc_media_player_set_drawable() */
void libvlc_video_set_parent( libvlc_instance_t *p_instance, libvlc_drawable_t d,
                              libvlc_exception_t *p_e )
{
    /* set as default for future vout instances */
    var_SetInteger(p_instance->p_libvlc_int, "drawable", (int)d);

    libvlc_media_player_t *p_mi = libvlc_playlist_get_media_player(p_instance, p_e);
    if( p_mi )
    {
        libvlc_media_player_set_drawable( p_mi, d, p_e );
        libvlc_media_player_release(p_mi);
    }
}