Results 1 to 2 of 2

Thread: Harmattan QUrl and QMediaPlayer problem with source

  1. #1
    Join Date
    Oct 2011
    Posts
    7
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Exclamation Harmattan QUrl and QMediaPlayer problem with source

    Hi!
    I'd post this thread in embedded section,
    but i consider this as a newbie question xD
    so i'm sorry if this is the wrong section.

    Okay, as the title says: In my application I'm trying to use QMediaPlayer to play music in my app, for Harmattan target.
    The sound files are included via deploymentfolders.

    From PC, it is already working: (in Qt Simulator)
    Qt Code:
    1. playlist->addMedia(QUrl::fromLocalFile("/files/sound_1.mp3"))
    To copy to clipboard, switch view to plain text mode 

    However, it's not working when installed in the device.
    I've been going back and forth with QA because of this, because I don't have a device to test
    and I think Harmattan QEMU and RDA doesnt give me sound output because Angry Birds has no sound.

    Things I've tried:
    - I noticed that the default working directory when I run the app is not in my application directory, so I've set it with
    Qt Code:
    1. QDir::setCurrent("/opt/myapp/")
    To copy to clipboard, switch view to plain text mode 
    by adding this code, the device can now read my textfiles ( with QFile )
    however QUrl still don't seem to work.

    -I've tried to write the absolute path of the file with:
    Qt Code:
    1. playlist->addMedia(QUrl::fromLocalFile(QDir::current().path() + QString("/files/sound_1.mp3")));
    To copy to clipboard, switch view to plain text mode 
    and still won't work.

    Please help.

    Big thanks!

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Harmattan QUrl and QMediaPlayer problem with source

    Your first code snippet is looking for a file at an absolute location (because of the leading '/') on the machine. I presume that location is not correct.

    Your second code snippet changes the current working directory of the process, but this will have no effect if you continue to request a file with an absolute path.

    Your third code snippet should find a file relative to the current working directory of the process (you could just use currentPath()), but is the current working directory where you think it is? If the file is installed and can be located relative to the executable then you should try: QCoreApplication::applicationDirPath() rather than relying on the current working directory.

    If this file is a permanent part of your application then you should consider building it into the executable using the Qt resource system.

Similar Threads

  1. Maemo5 / Harmattan application not showing in menu
    By andzero in forum Qt for Embedded and Mobile
    Replies: 2
    Last Post: 9th December 2011, 05:54
  2. Replies: 0
    Last Post: 10th October 2011, 08:11
  3. videoplayer problem in qmediaplayer
    By vinayaka in forum Newbie
    Replies: 3
    Last Post: 25th August 2011, 12:44
  4. Replies: 1
    Last Post: 29th March 2011, 10:12
  5. Problem with qurl and fromlocalfile
    By zorro68 in forum Qt Programming
    Replies: 1
    Last Post: 19th June 2008, 19:44

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.