Results 1 to 4 of 4

Thread: WebKit: how to force plugins (flash) to stop

  1. #1
    Join Date
    Jan 2010
    Posts
    2
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default WebKit: how to force plugins (flash) to stop

    Hi there,

    I'm using QtWebkit module to integrate a simple browser inside an own application.
    When I "switch off" the browser, I'd like the plugin as well to stop working.
    For example, if there's a flash video in playback when I close the browser window, I'd like to force stopping the flash plugin to render it.
    Instead I can still listen to the audio playback.
    I tried with:

    webPage->settings()->setAttribute(QWebSettings::PluginsEnabled, false);

    but this call only has effect when a new url is loaded.

    Any hints?
    Thanks,
    Ricky

  2. #2
    Join Date
    Sep 2010
    Posts
    1
    Thanked 1 Time in 1 Post
    Qt products
    PyQt3 PyQt4
    Platforms
    Unix/X11

    Default Re: WebKit: how to force plugins (flash) to stop

    Use QtWebKit.QWebPage.mainFrame().findAllElements() (using pyqt speak replace periods with colon for C) this gives you a QWebElementCollection
    which leads to a QWebElement and then look for tagName() == 'EMBED' and do QWebElement .removeFromDocument ()
    This will I suppose remove all plugin type elements from the page. You could do a more selective search using QWebElement.attributeNames ( ) .

    Here is snippet from my pyqt webkit browser I have it run at same time as I stop the javascript.

    absltlall = QtCore.QString('*')
    allinframe =crnt.Mpage.mainFrame().findAllElements ( absltlall)
    for z in allinframe:
    if z.tagName() == 'EMBED':
    z.removeFromDocument ()

    The above seems to work OK for me. . It is not completely pretty. Sometimes the element is removed and sometimes it is replaced with a blank space.

    I do not understand that CSS selector selector stuff and maybe you do not have to go through all the elements but use something more intelligent than my QtCore.QString('*') in the findAllElements ( )

  3. The following user says thank you to murdochrav for this useful post:

    rickyviking (17th September 2010)

  4. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: WebKit: how to force plugins (flash) to stop

    If you don't need the page anymore then delete it. Closing a webview will not cause it to be deleted automatically.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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

    rickyviking (17th September 2010)

  6. #4
    Join Date
    Jan 2010
    Posts
    2
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: WebKit: how to force plugins (flash) to stop

    Thank you for your replies, both methods work for me.
    Second is quick and clean, the only drawback is that it erases the history.

    Ricky

Similar Threads

  1. Using Qt4 with Flash
    By Strongoloid in forum Newbie
    Replies: 0
    Last Post: 10th November 2009, 22:36
  2. Replies: 0
    Last Post: 9th October 2009, 11:22
  3. Replies: 0
    Last Post: 19th March 2009, 14:51
  4. Replies: 0
    Last Post: 18th March 2009, 07:15
  5. QT and Flash
    By sawerset in forum Qt Programming
    Replies: 12
    Last Post: 1st September 2008, 08:51

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