Assert attempting to play audio in win8.1 project on Windows10

Very strange problem.
My code already works on iOS, Android and Mac.

With my game now updated to Cocos2d-x 3.9, using the win8.1-universal project (win32 project creates an executable that doesn’t run!!!).

Run my game…music plays :smile:
(quit game)
Run my game again…assert!!!

The game will NOT play music until I rename the audio file or rename the folder it’s in (eg. Resources/Audio/music.wav to Resources/WTF/music.wav), obviously I rename the filename/path within the code to reflect this change.

After renaming, it’ll run once, then everytime after…assert!!!

The assert is this one:

long FileUtils::getFileSize(const std::string &filepath)
{
    CCASSERT(false, "getFileSize should be override by platform FileUtils");
    return 0;
}

Someone else obviously has exactly the same issue here:

Also, I’ve checked that the file (& paths) have been copied across by VS into the “proj.win8.1-universal/Debug/mygame.Windows/AppX/Assets/Resources/” folder.

I also have the same issue! It doens’t work either on Windows 10 or Windows Phone.

If you rename the file and open renamed - it plays ok. If you try to play file after you launch the app for the second time - it fails.
If you stop/start the same music file during one session - it plays ok.

Can anyone help, please?

p.s. I have discovered that if you take background.mp3 from cpp-tests it works fine. It maybe file length or type or something else in mp3.

1 Like

Shame that it doesn’t work on the actual phone too.
I’ve added a Windows Phone to my Christmas list so I could test my game properly.

Also occurs after I converted my mp3 to a wav.

I now have a negative rating on Stackoverflow because I asked “did you find a solution?”.
Whilst I realise Stackoverflow isn’t a discussion board, I couldn’t see what else I could have done. Creating a new post would’ve just been a duplicate and got me marked down too.

Come on Cocos2d-x guys, can we have this looked into?

I’ve got it working by trimming sound file to 30 sec or less. 31 sec doesn’t work, 29 works. I don’t know the actual reason, but maybe something to do with buffer length?

1 Like

Very strange.
Because the music that doesn’t play (2nd time around) for me is only 22 seconds in length.

Can anybody from Cocos team look into it? This crappy bug stops us from putting our game to Greenlight and Windows Store :frowning:

1 Like

If it’s of any help to you, I lowered the bitrate of my music to get the file size down.
Although this worked for me, but it’s not a proper solution.

Ok, got it. It’s not that good fix, but still.
File: CCWinRTUtils.cpp
Method: createMappedCacheFile

I have commented if/else construction and call FileUtils::getInstance()->removeFile(prevFile) all the time.

Now it works fine. As I understand now the caching works only for current session.

It’s been fixed…

Click here