Results 1 to 5 of 5

Thread: ActiveX interface problem

  1. #1
    Join Date
    Oct 2009
    Location
    Hamburg - Germany
    Posts
    8
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question ActiveX interface problem

    Hello,

    i'm using qt 4.7.1 and MSVC++ 2008.

    My problem, i can't connect to any interfaces of the windows media player, by activeX.

    Small testprogramm

    mediaplayer_simple.pro
    Qt Code:
    1. TEMPLATE = app
    2. CONFIG += qaxcontainer
    3. HEADERS = playerwindow.h
    4. SOURCES = main.cpp \
    5. playerwindow.cpp
    To copy to clipboard, switch view to plain text mode 

    playerwindow.h
    Qt Code:
    1. #ifndef PLAYERWINDOW_H
    2. #define PLAYERWINDOW_H
    3.  
    4. #include <QWidget>
    5. class QAxWidget;
    6.  
    7. class PlayerWindow : public QWidget
    8. {
    9. public:
    10. PlayerWindow();
    11.  
    12. private:
    13. QAxWidget *wmp;
    14. };
    15.  
    16. #endif
    To copy to clipboard, switch view to plain text mode 

    playerwindow.cpp
    Qt Code:
    1. #include <QtGui>
    2. #include <QAxWidget>
    3. #include <QAxObject>
    4.  
    5. #include "playerwindow.h"
    6. #include <windows.h>
    7. #include <wmp.h>
    8.  
    9. PlayerWindow::PlayerWindow()
    10. {
    11. wmp = new QAxWidget(this);
    12. wmp->setControl("{6BF52A52-394A-11D3-B153-00C04F79FAA6}");
    13. wmp->setProperty("URL", "D:/clock.avi");
    14. qDebug("Version Info: %s", qPrintable(wmp->property("versionInfo").toString()));
    15.  
    16. IWMPMedia *media;
    17. wmp->queryInterface(QUuid(IID_IWMPMedia), (void **)&media);
    18. if (media)
    19. {
    20. double dur;
    21. media->get_duration(&dur);
    22. qDebug("Duration 2 %f", dur);
    23. media->Release();
    24. }
    25. else
    26. {
    27. qDebug("Failed");
    28. }
    29. }
    To copy to clipboard, switch view to plain text mode 

    main.cpp
    Qt Code:
    1. #include <QApplication>
    2. #include "playerwindow.h"
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. QApplication app(argc, argv);
    7. PlayerWindow playerWin;
    8. playerWin.show();
    9. return app.exec();
    10. }
    To copy to clipboard, switch view to plain text mode 


    Compiling failed, playerwindow.obj:: error: ... extern symbol "_IID_IWMPMedia" in Funktion ""public: __thiscall PlayerWindow::PlayerWindow(void)" (??0PlayerWindow@@QAE@XZ)".

    Original german compiler Message -->
    Verweis auf nicht aufgelöstes externes Symbol "_IID_IWMPMedia" in Funktion ""public: __thiscall PlayerWindow::PlayerWindow(void)" (??0PlayerWindow@@QAE@XZ)".


    Something is wanting by the compiler, but i don't know what.
    Anybody an idea?

  2. #2
    Join Date
    Jul 2009
    Posts
    74
    Thanks
    2
    Thanked 6 Times in 6 Posts

    Default Re: ActiveX interface problem

    wmp.h is has been generated with dumpcpp?

  3. #3
    Join Date
    Oct 2009
    Location
    Hamburg - Germany
    Posts
    8
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: ActiveX interface problem

    Hi javimoya,

    no, it's from folder of "Microsoft SDKs\Windows\v6.0A\Include ... the Windows SDK include also the windows media player sdk.
    I see, i forgot it at the project file ... testing with path in HEADERS to wmp.h fails.

  4. #4
    Join Date
    Jul 2009
    Posts
    74
    Thanks
    2
    Thanked 6 Times in 6 Posts

    Default Re: ActiveX interface problem

    in your initial posted example try this:

    1)
    add this:
    #include <InitGuid.h>

    2)
    change:
    wmp->queryInterface(QUuid(IID_IWMPMedia), (void **)&media);
    for:
    wmp->queryInterface(QUuid(__uuidof(IWMPMedia)), (void **)&media);

    it will compile
    :-)


    Added after 14 minutes:


    anyway the rest of your code is wrong...

    try in this way:

    Qt Code:
    1. wmp->setControl("{6BF52A52-394A-11D3-B153-00C04F79FAA6}");
    2. wmp->setProperty("URL", "C:/Windows/Media/chimes.wav"); // put your video here
    3. QAxObject* currentMedia= wmp->querySubObject("currentMedia");
    4.  
    5. IWMPMedia *media;
    6. currentMedia->queryInterface(QUuid(__uuidof(IWMPMedia)), (void **)&media);
    7. if (media)
    8. {
    9.  
    10. double dur;
    11. media->get_duration(&dur);
    12. qDebug("Duration 2 %f", dur);
    13. media->Release();
    14. }
    15. else
    16. {
    17. qDebug("Failed");
    18. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by javimoya; 8th January 2011 at 14:31.

  5. The following user says thank you to javimoya for this useful post:

    skyperhh (9th January 2011)

  6. #5
    Join Date
    Oct 2009
    Location
    Hamburg - Germany
    Posts
    8
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: ActiveX interface problem

    Hi javimoya,
    great work, Thank you very much !!

    But, there is also a "small" problem... the values of duration time are zero, did you see the duration time? ... But, I'am thinking, i must wait a little bit and check IWMPCore::get_openState before asking... more tomorrow. :-)

    Qt Code:
    1. PlayerWindow::PlayerWindow()
    2. {
    3. wmp = new QAxWidget(this);
    4. wmp->setControl("{6BF52A52-394A-11D3-B153-00C04F79FAA6}");
    5. wmp->setProperty("URL", "C:/Windows/Media/notify.wav");
    6.  
    7. QAxObject* currentMedia = wmp->querySubObject("currentMedia");
    8. //qDebug("Version Info: %s", qPrintable(wmp->property("versionInfo").toString()));
    9.  
    10. IWMPMedia *media;
    11. currentMedia->queryInterface(QUuid(__uuidof(IWMPMedia)), (void **)&media);
    12. if (media)
    13. {
    14. double dur = 1.0;
    15. HRESULT hr;
    16. hr = media->get_duration(&dur);
    17. if (hr == S_OK)
    18. qDebug("The method succeeded.");
    19. qDebug("Duration %f", dur);
    20.  
    21. BSTR pbstrDuration;
    22.  
    23. hr = media->get_durationString(&pbstrDuration);
    24. if (hr == S_OK)
    25. qDebug("The method2 succeeded.");
    26.  
    27. QString str;
    28. int len = wcslen( pbstrDuration );
    29. str.setUnicode( (QChar*)pbstrDuration, len );
    30.  
    31. qDebug("Duration string %s", qPrintable(str));
    32.  
    33. media->Release();
    34. }
    35. else
    36. {
    37. qDebug("Failed");
    38. }
    39. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Get the iDispatch interface of an ActiveX control
    By punkypogo in forum Qt Programming
    Replies: 1
    Last Post: 17th August 2010, 08:00
  2. Problem with design interface
    By tux-world in forum Newbie
    Replies: 5
    Last Post: 10th March 2010, 14:19
  3. ActiveX
    By franco.amato in forum Qt Programming
    Replies: 6
    Last Post: 29th December 2009, 17:06
  4. ActiveX problem with ie8
    By ftrastour in forum Qt Programming
    Replies: 0
    Last Post: 9th November 2009, 13:03
  5. How can i use ActiveX
    By mmg123 in forum Qt Tools
    Replies: 6
    Last Post: 3rd October 2006, 11:18

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.