Page 1 of 2 12 LastLast
Results 1 to 20 of 22

Thread: QuickTime API

  1. #1
    Join Date
    Jan 2007
    Posts
    326
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default QuickTime API

    Hi all

    http://doc.trolltech.com/qq/qq20-hiviews.html

    I had used the above API of QuickTime to display movies , but the problem is
    that i am having a list of files in QTreeWidget , on double click on an item , I am saving the file and then calling this API , the file Plays , but sometimes after playing some files, when i click on another file to play ,the balnk screen displays but the movie widget and controllers are not visible on the screen, I dont know why it is happening.

    Regards
    Merry
    Always Believe in Urself
    Merry

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QuickTime API

    So, what do you expect us to do without giving a single line of code?
    J-P Nurmi

  3. #3
    Join Date
    Jan 2007
    Posts
    326
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: QuickTime API

    I had given the link , In this link Full Source code is available for displaying movies (himovieview), I used same code , but the difference is this much only that in this , file is selected using QFileDialog and I am selecting file using QTreeWidget, that is I am having a QTreeWidget , in which there is a list of files, and on double click on the file , the player is being visible and load the file.

    Regards
    Merry
    Always Believe in Urself
    Merry

  4. #4
    Join Date
    Jan 2007
    Posts
    326
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: QuickTime API

    Hi all

    I think there is a problem of Memory Leakage in the QuickTime Player API. (http://doc.trolltech.com/qq/qq20-hiviews.html).
    Source code is available in the above link
    Can anybody tells me How to handle the problem of Memory leakage in this API.

    Regards
    Merry
    Always Believe in Urself
    Merry

  5. #5
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QuickTime API

    Quote Originally Posted by merry View Post
    I had given the link , In this link Full Source code is available for displaying movies (himovieview), I used same code , but the difference is this much only that in this , file is selected using QFileDialog and I am selecting file using QTreeWidget, that is I am having a QTreeWidget , in which there is a list of files, and on double click on the file , the player is being visible and load the file.
    So, are you able to reproduce the problem with the example code? If not, most likely the problem is in your code.

    Quote Originally Posted by merry View Post
    I think there is a problem of Memory Leakage in the QuickTime Player API. (http://doc.trolltech.com/qq/qq20-hiviews.html).
    Source code is available in the above link
    Can anybody tells me How to handle the problem of Memory leakage in this API.
    What actions did you take to verify that there is a memory leak? Also, I suppose you mean that the sample application has a memory leak.
    J-P Nurmi

  6. #6
    Join Date
    Jan 2007
    Posts
    326
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: QuickTime API

    Thanks for the reply.

    I saw it through the "ActivityMonitor"

    Actually what i am exactly doing is this when the user double click on the file in the QTreeWidget, the file get saved and after saving the file , a signal is emitted for loading the movie in the MovieWidget, and when the movie is loaded , i 'll delete that saved file,

    Through the activity monitor i saw , Till then free memory is available the files are loaded in the movie widget and when free space available is less than the file size then the widget appears but with no controllers , that is only a blank screen appears.

    Then i thought its a Memory Leakage problem at the time of movie load.

    Regards
    Merry
    Always Believe in Urself
    Merry

  7. #7
    Join Date
    Jan 2007
    Posts
    326
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: QuickTime API

    Hi all

    I got the problem where the memory leaks.

    On Every double click on the QTreeWidgetItem, When I call the QuickTimeMovie Player,then every time I' ll make the new Player, due to which there is lots of memory leakage.

    Qt Code:
    1. Window *movieWindow = new Window(0);
    2. connect(this,SIGNAL(movieChosen(QString)),movieWindow,SLOT(OpenMovie(QString))),
    3. movieWindow->show();
    To copy to clipboard, switch view to plain text mode 

    Is there any other way , that on doubleClick on the QTreeWidgetItem, I dont have to make the new Player.

    If i make it member variable, then it crashes. what to do?


    Regards
    Merry
    Always Believe in Urself
    Merry

  8. #8
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QuickTime API

    Quote Originally Posted by merry View Post
    I got the problem where the memory leaks.

    On Every double click on the QTreeWidgetItem, When I call the QuickTimeMovie Player,then every time I' ll make the new Player, due to which there is lots of memory leakage.
    You allocate QObjects without parent and never delete them? Yes, that's a memory leak.

    Is there any other way , that on doubleClick on the QTreeWidgetItem, I dont have to make the new Player.

    If i make it member variable, then it crashes. what to do?
    My wild guess is that even if you declare a member variable you assign to a local variable.
    J-P Nurmi

  9. #9
    Join Date
    Jan 2007
    Posts
    326
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: QuickTime API

    Thanks 4 the reply

    You allocate QObjects without parent and never delete them? Yes, that's a memory leak.
    How can I stop this memory leak.

    My wild guess is that even if you declare a member variable you assign to a local variable.
    I declare it as a Global Variable.
    Always Believe in Urself
    Merry

  10. #10
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QuickTime API

    Quote Originally Posted by merry View Post
    How can I stop this memory leak.
    Re-use same component or deallocate the previous one before allocating a new one.

    I declare it as a Global Variable.
    I'd advise not to do that. Using global variables tend to lead to unreadable and unmaintainable error-prone code.
    J-P Nurmi

  11. #11
    Join Date
    Jan 2007
    Posts
    326
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: QuickTime API

    Hi

    Re-use same component or deallocate the previous one before allocating a new one.
    I am reusing the same component, but when i make it close, it crashes.

    connect(btn_close, SIGNAL(clicked()), this, SLOT(close()));
    and if I not close it using the above statement and close it using the close from the upper left corner , then it works fine,

    What is the difference between the two close.

    I had used the QPushButton to close ,To set the widget Modal.

    Regards
    Merry
    Always Believe in Urself
    Merry

  12. #12
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QuickTime API

    Quote Originally Posted by merry View Post
    I am reusing the same component, but when i make it close, it crashes.
    Run your application via debugger and see the backtrace. Don't try to guess the reason. Use available tools to conclude the reason.

    and if I not close it using the above statement and close it using the close from the upper left corner , then it works fine,

    What is the difference between the two close.

    I had used the QPushButton to close ,To set the widget Modal.
    Sorry, I don't understand the problem description. Could you rephrase?
    J-P Nurmi

  13. #13
    Join Date
    Jan 2007
    Posts
    326
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: QuickTime API

    Hi

    Run your application via debugger and see the backtrace. Don't try to guess the reason. Use available tools to conclude the reason.
    Really , i am not guessing.

    Actually , I already told you that I am having a Widget , in Which there is a QTreeWidget, and when i double click on the QTreeWidgetItem ,i make the moviePlayer widget visible,
    To set the moviePlayer widget modality , I use

    moviePlayerwidget->setModality(QApplication::Modal)
    due to which the Close button on the upperLeft corner dissapears. and for closing the moviePlayerwidget, I use

    connect(btn_close, SIGNAL(clicked()), this, SLOT(close()));
    , using this
    the process crashes.

    But , if I wont set the modality , then the Close button on the upperLeft corner is visible,

    and when i use Close button on the upperLeft corner to close, It not crashes,

    I dont understand the difference between the two closes ,

    Or

    Tell me the other alternative , that without setting the modality ,moviePlayerWidget comes over the other widget. , because If I wont set the modality of moviePlayerWidget, It comes behind the other widget.

    Hope so now you understand my problem.

    Thanx
    Attached Images Attached Images
    Always Believe in Urself
    Merry

  14. #14
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QuickTime API

    Quote Originally Posted by merry View Post
    Really , i am not guessing.

    Actually , I already told you that I am having a Widget , in Which there is a QTreeWidget, and when i double click on the QTreeWidgetItem ,i make the moviePlayer widget visible
    Yes, that's what you have told us. However, that's extremely high-level description. Remember that we haven't seen a single line of code. There's really no way for us to help solving the problem if that's all what you tell us. You have to help us to help you. A backtrace mostly gives a clear picture of the situation when a crash occurs.
    J-P Nurmi

  15. #15
    Join Date
    Jan 2007
    Posts
    326
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: QuickTime API

    Hi

    In the below code when i tries to close the dialog ,through the button I used in Window class then application crashes, but if I close it through the close button that is on the upper left corner that is "X" then it wont crashes and works fine and also no memory leakage. For this I use QDialog.exec() , So that modality should also set and "X" should also be visible but, using this QDialog.exec() also "X" Should not be visible.

    Qt Code:
    1. [B][U]SelectFile.cpp[/U][/B]
    2.  
    3. void SelectFile::init()
    4. {
    5. connect(btn_SelectFile,SIGNAL(clicked()),this,SLOT(chooseMovie()));
    6. }
    7.  
    8. void SelectFile::chooseMovie()
    9. {
    10. QString TmpStr = QFileDialog::getOpenFileName(this);
    11. EnterMovies();
    12. if(movieWindow==NULL)
    13. Window *movieWindow = new Window(0);
    14. connect(this,SIGNAL(movieChosen(QString)),movieWindow,SLOT(OpenMovie(QString)));
    15. emit movieChosen(TmpStr);
    16. movieWindow->exec();
    17. ExitMovies();
    18. }
    19.  
    20.  
    21. [B][U]window.cpp[/U][/B]
    22.  
    23.  
    24. Window::Window(QWidget *parent)
    25. : QDialog(parent)
    26. {
    27. setupUi(this);
    28. movieWidget = new MovieWidget(this);
    29. connect(this, SIGNAL(movieChoose(QString)),movieWidget,SLOT(loadMovie (QString)));
    30. connect(movieWidget, SIGNAL(optimalSizeChange()),this, SLOT(updateSizes()));
    31. connect(movieWidget, SIGNAL(NoPreview()),this, SIGNAL(NoPreviewAvailable()));
    32. connect(btn_close, SIGNAL(clicked()), this, SLOT(Close()));
    33. layout()->addWidget(movieWidget);
    34. }
    35.  
    36. Window::~Window()
    37. {
    38.  
    39. }
    40.  
    41. void Window::Close()
    42. {
    43. connect(this, SIGNAL(DisposeCurrentMovie()),movieWidget,SLOT(dispose()));
    44. close();
    45. }
    46. void Window :: OpenMovie(QString bMovieName)
    47. {
    48. emit movieChoose(bMovieName);
    49. }
    50. void Window::updateSizes()
    51. {
    52. adjustSize();
    53. }
    54.  
    55.  
    56. [B][U]moviewidget.cpp
    57. [/U][/B]
    58. #include "moviewidget.h"
    59. #include <QtGui/QLayout>
    60. #include <Carbon/Carbon.h>
    61. #include <QuickTime/QuickTime.h>
    62.  
    63. MovieWidget::MovieWidget(QWidget *parent)
    64. : QWidget(parent), currentMovie(0)
    65. {
    66. HIViewRef movieView;
    67. HIObjectCreate(kHIMovieViewClassID, 0, reinterpret_cast<HIObjectRef*>(&movieView));
    68. HIMovieViewChangeAttributes(movieView,
    69. kHIMovieViewAutoIdlingAttribute | kHIMovieViewControllerVisibleAttribute, 0);
    70.  
    71. create(WId(movieView));
    72. setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
    73.  
    74. }
    75.  
    76. MovieWidget::~MovieWidget()
    77. {
    78. if (currentMovie)
    79. DisposeMovie(currentMovie);
    80. }
    81.  
    82. void MovieWidget::dispose()
    83. {
    84. if (currentMovie)
    85. DisposeMovie(currentMovie);
    86. }
    87.  
    88. void MovieWidget::loadMovie(const QString &fileName)
    89. {
    90. QTVisualContextRef visualContext = 0;
    91. Boolean active = true;
    92. DataReferenceRecord dataRef;
    93. Movie oldMovie = 0;
    94.  
    95.  
    96.  
    97. // create an array of properties for NewMovieFromProperties
    98. // these properties describe how to create the new movie
    99. // see Movies.h for the full list of available properties
    100. QTNewMoviePropertyElement newMovieProperties[] = {
    101. {kQTPropertyClass_DataLocation, kQTDataLocationPropertyID_DataReference, sizeof(dataRef), &dataRef, 0},
    102. {kQTPropertyClass_NewMovieProperty, kQTNewMoviePropertyID_Active, sizeof(active), &active, 0},
    103. {kQTPropertyClass_Context, kQTContextPropertyID_VisualContext, sizeof(visualContext), &visualContext, 0},
    104. };
    105.  
    106. CFStringRef cfString = CFStringCreateWithCharacters(0,
    107. reinterpret_cast<const UniChar *>(fileName.unicode()),
    108. fileName.length());
    109. QTNewDataReferenceFromFullPathCFString(cfString, kQTPOSIXPathStyle, 0, &dataRef.dataRef, &dataRef.dataRefType);
    110. CFRelease(cfString);
    111.  
    112.  
    113. // if there's an old movie save it so we can dispose of it if
    114. // we load up a new movie successfully
    115. oldMovie = currentMovie;
    116. currentMovie = 0;
    117.  
    118. // create a new movie using movie properties
    119. // when calling this function, you supply a set of input properties that describe the information
    120. // required to instantiate the movie (its data reference, audio context, visual context, and so on)
    121. NewMovieFromProperties(sizeof(newMovieProperties) / sizeof(newMovieProperties[0]), // the number of properties in the array passed in inputProperties
    122. newMovieProperties, // a pointer to a property array describing how to instantiate the movie
    123. 0, // number of properties in the array passed in outputProperties
    124. 0, // pointer to a property array to receive output parameters - 0 if you don’t want this information
    125. &currentMovie); // pointer to a variable that receives the new movie
    126. // make sure to dispose of the dataRef we no longer need it
    127. DisposeHandle(dataRef.dataRef);
    128.  
    129. // set the HIMovieView's current movie
    130. HIMovieViewSetMovie(HIViewRef(winId()), currentMovie);
    131.  
    132. if (oldMovie != 0)
    133. DisposeMovie(oldMovie);
    134.  
    135. if(currentMovie == 0)
    136. emit NoPreview();
    137. // new movie has a new size, need to update.
    138. updateGeometry();
    139. emit optimalSizeChange();
    140.  
    141. }
    142.  
    143. QSize MovieWidget::sizeHint() const
    144. {
    145. EventRef event;
    146. HIRect optimalBounds;
    147. CreateEvent(0, kEventClassControl, kEventControlGetOptimalBounds,
    148. GetCurrentEventTime(), kEventAttributeUserEvent, &event);
    149. SendEventToEventTargetWithOptions(event,
    150. HIObjectGetEventTarget(HIObjectRef(winId())),
    151. kEventTargetDontPropagate);
    152. GetEventParameter(event, kEventParamControlOptimalBounds, typeHIRect,
    153. 0, sizeof(HIRect), 0, &optimalBounds);
    154. ReleaseEvent(event);
    155. return QSize(optimalBounds.size.width, optimalBounds.size.height);
    156. }
    157.  
    158. bool MovieWidget::nativeControlsVisible() const
    159. {
    160. OptionBits currentBits = HIMovieViewGetAttributes(HIViewRef(winId()));
    161. return currentBits & kHIMovieViewControllerVisibleAttribute;
    162. }
    163.  
    164. void MovieWidget::setNativeControlsVisible(bool visible)
    165. {
    166. if (visible != nativeControlsVisible()) {
    167. HIMovieViewChangeAttributes(HIViewRef(winId()),
    168. visible ? kHIMovieViewControllerVisibleAttribute : 0,
    169. !visible ? kHIMovieViewControllerVisibleAttribute : 0);
    170. updateGeometry();
    171. emit optimalSizeChange();
    172.  
    173. }
    174. }
    To copy to clipboard, switch view to plain text mode 


    Regards
    Merry
    Always Believe in Urself
    Merry

  16. #16
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QuickTime API

    I'm surprised it works at all.
    Qt Code:
    1. if(movieWindow==NULL) // tests a member variable
    2. Window *movieWindow = new Window(0); // assigns to a new local variable, NOT to the member variable
    3. connect(this,SIGNAL(movieChosen(QString)),movieWindow,SLOT(OpenMovie(QString))); // uses the member variable
    4. emit movieChosen(TmpStr);
    5. movieWindow->exec(); // uses the member variable
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  17. #17
    Join Date
    Jan 2007
    Posts
    326
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: QuickTime API

    Qt Code:
    1. if(movieWindow==NULL) // tests a member variable
    2. Window *movieWindow = new Window(0);
    To copy to clipboard, switch view to plain text mode 

    Sorry By Mistake I had written this ,In my code I had taken it as a member Variable.

    Qt Code:
    1. if(movieWindow==NULL) // tests a member variable
    2. movieWindow = new Window(0);
    To copy to clipboard, switch view to plain text mode 
    Always Believe in Urself
    Merry

  18. #18
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QuickTime API

    The next step is to instantiate the modal dialog on the stack. You might also want to pass a proper parent to make dialog appear properly over its parent:
    Qt Code:
    1. Window movieWindow(this); // parent
    2. movieWindow.OpenMovie(TmpStr);
    3. movieWindow.exec(); // blocks
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  19. #19
    Join Date
    Jan 2007
    Posts
    326
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: QuickTime API

    Thanks for the reply.
    But on using this , Still "X" is dissabled, Is some flags to be set
    Always Believe in Urself
    Merry

  20. #20
    Join Date
    Jan 2007
    Posts
    326
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: QuickTime API

    Using QDialog.exec() Still "All the three buttons are disabled" on the upper Left corner, that
    is (x) (-) & (+).

    Please tell me what should i do,

    Regards
    Merry
    Always Believe in Urself
    Merry

Similar Threads

  1. [MAC] Quicktime Widget
    By dlpnet in forum Qt Programming
    Replies: 3
    Last Post: 29th January 2008, 11:30
  2. Replies: 7
    Last Post: 28th January 2007, 11:07

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.