Results 1 to 6 of 6

Thread: Unable to embed VLC in Qt-Widget MacOS

  1. #1
    Join Date
    Jan 2011
    Posts
    55

    Unable to embed VLC in Qt-Widget MacOS

    I am currently looking to integrate VLC into the custom application which should be portable between Mac and Windows. I have used the Alexander Maringer in the Wiki and I have successfully embedded VLC through Qt-application on the Windows. However I have tried to do the same with the Mac but it did not working. The App is seems to crash every time when I am trying the same. Let me know if you are having any suggestion to meet the requirement of mine. Thanks a lot in advance.

  2. #2
    Join Date
    Nov 2008
    Posts
    1,192

    Re: Unable to embed VLC in Qt-Widget MacOS

    Well according to me one should remove the macosx-plugin from the computer and one should try with the 1.0.0 release candidate. QuickTime 4.5 is now having QMacCocoaViewContainer which is wrapping Cocoa NSView into the QWidget. Another one thing you can try libvlc_media_player_set_nsobject apart from the pointer not just to the NSView to render and not the instance of the VLCOpenGLVoutView which is located at the /modules/minimal_macosx/VLCOpenGLVoutView.h location.

  3. #3
    Join Date
    Jun 2009
    Posts
    1,518

    Re: Unable to embed VLC in Qt-Widget MacOS

    I am suggesting the following thing which you can use to fix the problem of yours. You need to put libvlc headers and Qt headers in to folder and run the same.
    Code:
    qmake -project
    Now you should edit the .pro file and add the following things.
    Code:
    LIBS += -L*path to vlc lib* #if you are at windows os
    LIBS += -lvlc
    Now run the File.
    Code:
    Qmake
    Finally use the following thing on the terminal.
    Code:
    make or mingw32-make under a Windows OS

  4. #4
    Join Date
    Nov 2008
    Posts
    1,514

    Re: Unable to embed VLC in Qt-Widget MacOS

    I am having particular solution which you can use to fix the problem of yours.
    You should do the following changes into main.cpp
    Code:
    - |   QFrame *_videoWidget;
    
    + |   QMacCocoaViewContainer *_videoWidget;
    Now do the following changes into vlc_on_qt.mm.
    Code:
    + |   #undef slots  
    + |   // yes, otherwise there's a confilct in some framework's header file 
    + |   // please, suggest a cleaner way to do that.
    
    + |   #import <VLCKit/VLCKit.h>
    ___________________________________________________________________________
    - |   libvlc_media_player_set_agl (_mp, _videoWidget->winId(), &_vlcexcep); // for vlc 1.0
    
    + |   VLCVideoView *videoView = [[VLCVideoView alloc] init];
    + |   _videoWidget->setCocoaView(videoView);   
    + |   [videoView setAutoresizingMask: NSViewHeightSizable|NSViewWidthSizable];
    + |   libvlc_media_player_set_nsobject(_mp, videoView, &_vlcexcep);
    I am hoping that it will help you out to solve the problem of yours.

  5. #5
    Join Date
    Mar 2009
    Posts
    1,360

    Re: Unable to embed VLC in Qt-Widget MacOS

    Well after using the above mentioned solution you will see that the VLC would be hanging. You can solve the matter by simply creating the symbolic link between lib and modules to the respective directories into the <Application bundle>/Contents/Frameworks/Versions/Current/. Rather than duplicating libraries of the bundle. I am hoping that the solution which would be helpful to solve the problem of yours.

  6. #6
    Join Date
    Nov 2008
    Posts
    1,259

    Re: Unable to embed VLC in Qt-Widget MacOS

    I am providing some code of the libvlc wrapper over here which would be helpful to you.
    Code:
    Constructor 
    LCPlayer::VLCPlayer()
       : QWidget()
    {
       const char * const vlc_args[] = {
             "-I", "dummy"         // Don't use any interface
             ,"--ignore-config"      // Don't use VLC's config
             ,"--verbose=-1"
             ,"--quiet"
       #ifdef Q_WS_MAC
                      , "--vout=minimal_macosx"
                      , "--opengl-provider=minimal_macosx"
       #endif
          };
    
          
       int argc = sizeof(vlc_args) / sizeof(vlc_args[0]);
    
       _vlcinstance   = libvlc_new( argc, vlc_args, &VLCException(this) );
       _media_player   = libvlc_media_player_new( _vlcinstance, &VLCException(this) );
       _media_descr    = NULL;
    
       #ifdef Q_WS_MAC && VLC_VERSION_1_0
          _videoWidget = NULL;
          _wrapperLayout = new QVBoxLayout;
          _wrapperLayout->setContentsMargins(0,0,0,0);
          setLayout(_wrapperLayout);
       #endif
    
       // Create a timer to poll player state. That way it works. Using vlc's event manager caused some problems with threads.
    
            // That's it. Window will be attached once we actually start playing.
    }
    Code:
     Destructor 
    VLCPlayer::~VLCPlayer()
    {
       _poller->stop();
       Stop();
       libvlc_media_player_release (_media_player);
       libvlc_release (_vlcinstance);   
    }
    Load
    Code:
    void   VLCPlayer::Load( IN QString & url)
    {
       Stop();
    
       if (_media_descr) libvlc_media_release( _media_descr );
       _media_descr = libvlc_media_new (_vlcinstance, url.toAscii(), &VLCException(this) );
    
       // Creating parameter string 'options'
    
       libvlc_media_add_option      ( _media_descr,   options,   &VLCException(this) );
       libvlc_media_player_set_media   ( _media_player, _media_descr,   &VLCException(this) );
    
       attachPlayerToWnd();
    }
    attachPlayerToWnd()
    Code:
    // Tell LibVLC to render video into our widget 
    void VLCPlayer::attachPlayerToWnd()
    {
       #if defined(Q_WS_WIN)
          #if defined( VLC_VERSION_0_9 )
             libvlc_media_player_set_drawable(_media_player, reinterpret_cast<unsigned int>(winId()), &VLCException(this) );
          #elif defined ( VLC_VERSION 1_0 )
             libvlc_media_player_set_hwnd(_media_player, winId(), &VLCException(this) );
          #endif
       #elif defined(Q_WS_MAC)
          #if defined( VLC_VERSION_0_9 )
             libvlc_media_player_set_drawable(_media_player, winId(), &VLCException(this) );
          #elif defined( VLC_VERSION_1_0 )
    
             _videoWidget = new QMacCocoaViewContainer(0);
             _wrapperLayout->addWidget(_videoWidget);
       
             NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
             
             VLCVideoView *videoView = [[VLCVideoView alloc] init]; 
             _videoWidget->setCocoaView(videoView);
             
             libvlc_media_player_set_nsobject(_media_player, videoView, &VLCException(this) );
             [videoView release];
             
             [pool release];
    
             //@
             _videoWidget->hide();
          #endif
       #elif defined( Q_WS_X11 ) 
          #if defined( VLC_VERSION_0_9 )
             libvlc_media_player_set_drawable(_media_player, winId(), &VLCException(this) );
          #elif defined( VLC_VERSION_1_0 )
             libvlc_media_player_set_xwindow(_media_player, winId(), &VLCException(this) );
          #endif
       #endif
    }
    
     Finally code for the Play and stop options of the VLC.
    void   VLCPlayer::Play()
    {
       libvlc_media_player_play( _media_player, &VLCException(this) );
       
       #ifdef Q_WS_MAC
          if (_videoWidget) _videoWidget->show();
       #endif
    
       _poller->start();
    }

Similar Threads

  1. Unable to load widget after rebooting LG Revolution
    By GanMan in forum Portable Devices
    Replies: 10
    Last Post: 29-12-2011, 02:18 PM
  2. Unable to add widget in Sony Ericsson Xperia Arc
    By Harin$Akshi in forum Portable Devices
    Replies: 6
    Last Post: 14-05-2011, 03:38 PM
  3. Unable to reinstall a Widget 2.0.
    By Tallulah in forum Windows Software
    Replies: 5
    Last Post: 19-04-2011, 10:42 PM
  4. Embed Weather Widget to Webpage
    By Benjycool in forum Software Development
    Replies: 3
    Last Post: 23-05-2009, 07:27 PM
  5. Unable to embed an OLE object in an Access OLE field
    By Santanio in forum Windows Software
    Replies: 2
    Last Post: 05-05-2009, 11:56 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,751,027,264.46959 seconds with 16 queries