Forums

OverviewFelgo 2 Support (Qt 5) › Issue with C++ asset paths vs QML

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #18676

    Kool

    Hi All,

    I have some audio mp3 files in my assets folder. I initially played them using a simple Audio QML item with the path:

    source: "../../assets/some_audio.mp3"

    This worked fine, but for various reasons I decided to the move loading/playing of audio files into C++ land, using a combination of QMediaPlayer (to play the files) and QMediaPlaylist (to store all the paths to files).

    The QMediaPlaylist (C++) accepts a QUrl as a path to an audio file:

    playlist_->addMedia(QUrl("assets/some_audio.mp3");

    It locates it and plays the file fine on Windows.

    However, it cannot locate the file on Android deployments. Does anyone have any ideas what might be wrong/a quick solution? (please forgive the lack of example code)

    Many thanks!

    #18686

    Günther
    Felgo Team

    Hi Kool!

    The assets might be placed differently depending on the app packaging required for the platform. You can check each application package and platform where to locate the files, to add platform-dependent code accordingly.

    Best,
    Günther

    #18693

    Kool

    GT said:

    Hi Kool!

    The assets might be placed differently depending on the app packaging required for the platform. You can check each application package and platform where to locate the files, to add platform-dependent code accordingly.

    Best,
    Günther

    That does seem to be the case. If there’s one thing I hate it’s adding macro ifdefs all over my code.

    I do wonder how the Audio::source component/property correctly resolves it on both Android and Windows without any intervention.

    Does anyone know how to get to the source code for that to see how Qt does it?

    #18696

    Kool

    I tried for a while testing out various things but nothing worked.

    Qt’s documentation points to this page: https://wiki.qt.io/Qt_for_Android_known_issues

    The Qt Multimedia Widgets module is not supported on Android, which means video display is only available using the VideoOutput and Video QML items.
    

    This may indicate the QMediaPlayer class is incompatible with Android. However, some stack overflow posts mention getting it to work on Android.

    At this point I’ll just revert back to the previous QML implementation.

Viewing 4 posts - 1 through 4 (of 4 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support