Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QMediaPlayer isn't defined. Python.
Qt 6.11 is out! See what's new in the release blog

QMediaPlayer isn't defined. Python.

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 739 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mr.S.
    wrote on last edited by Mr.S.
    #1

    Hi, everybody.
    I'm trying to use PySide2 with Python. Accordring to this page there should be QMediaPlayer class:
    https://doc.qt.io/qtforpython/PySide2/QtMultimedia/QMediaPlayer.html

    But when I'm trying to instantiate it:

    import PySide2
    player = QMediaPlayer

    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    NameError: name 'QMediaPlayer' is not defined

    1 Reply Last reply
    0
    • M Mr.S.

      There is no "new" operator in Python. To create object it should be done as I did. Those examples at the link are for C++ obviously, though the page purposed for Python.
      And if somebody know where to send a notice about this... so they would fix the page.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #4

      @Mr-S
      At a guess, the import should be:

      from PySide2.QtMultimedia import QMediaPlayer
      

      ?

      1 Reply Last reply
      1
      • martial123M Offline
        martial123M Offline
        martial123
        wrote on last edited by
        #2

        Hi Mr.S, "new" is missing before QMediaPlayer to create your object player .

        1 Reply Last reply
        0
        • M Offline
          M Offline
          Mr.S.
          wrote on last edited by Mr.S.
          #3

          There is no "new" operator in Python. To create object it should be done as I did. Those examples at the link are for C++ obviously, though the page purposed for Python.
          And if somebody know where to send a notice about this... so they would fix the page.

          JonBJ 1 Reply Last reply
          0
          • M Mr.S.

            There is no "new" operator in Python. To create object it should be done as I did. Those examples at the link are for C++ obviously, though the page purposed for Python.
            And if somebody know where to send a notice about this... so they would fix the page.

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by JonB
            #4

            @Mr-S
            At a guess, the import should be:

            from PySide2.QtMultimedia import QMediaPlayer
            

            ?

            1 Reply Last reply
            1
            • M Offline
              M Offline
              Mr.S.
              wrote on last edited by
              #5

              That's right, thank you very much, John.

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved