QMediaResource::dataSize() returns zero byte size for online video

  • I am trying to use QMediaResource::dataSize() to get an online video byte size. However, it just returns zero - which is hard to believe in this case:

    This may be zero if the size is unknown.

    especially for the first url.

    I just want to know: (1) if it is a bug with PyQt5 or Qt5, (2) does the equivalent code in Qt5 return a nonzero result, and (3) is there any way to get the video byte size of the m3u8 url referred to?

    >>> from PyQt5.QtMultimedia import *
    >>> from PyQt5.QtCore import *
    >>> QMediaResource(QUrl('http://downdb.51voa.com/201610/will-philippines-cut-ties-with-us-and-grow-closer-to-china.mp3')).dataSize()
    >>> QMediaResource(QUrl('https://www.the5fire.com/static/demos/diaosi.m3u8'),"application/vnd.apple.mpegurl").dataSize()

    >>> QMediaResource(QNetworkRequest(QUrl('https://www.the5fire.com/static/demos/diaosi.m3u8')),"application/vnd.apple.mpegurl").dataSize()
    >>> QMediaResource(QNetworkRequest(QUrl('https://www.the5fire.com/static/demos/diaosi.m3u8'))).dataSize()
    >>> QMediaResource(QNetworkRequest(QUrl('http://downdb.51voa.com/201610/will-philippines-cut-ties-with-us-and-grow-closer-to-china.mp3'))).dataSize()

  • Moderators

    m3u is a playlist format. And playlist may contain multiple media urls.
    Also note that the byte size isn't guaranteed to be known, depending on the webserver implementation.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.