[wp8] PlayerEffect fails to find file in open... I swear it is there.

[wp8] PlayerEffect fails to find file in open... I swear it is there.
0.0 0


I have an iOS cocos2d-iphone app in the app store which is all well and good but I am trying to port it to Windows Phone 8 by basically copying and pasting the Objective-C code into each method and writing the Cocos2d-x C*+ equivalent.
// playEffect:@“CardDeal-1a.mp3”];
I have added the mp3 file in the exact same place as where it picking up and showing image files in CCSprites…
It throws this exception
throw ref new Platform::FailureException;
stack trace…
Msvcr110d.dll!_CxxThrowException Line 152 C*+
CocosDenshionWindowsPhone.dll!MediaStreamer::ReadData(Platform::String ^ filename) Line 71 C*+
CocosDenshionWindowsPhone.dll!MediaStreamer::Initialize Line 108 C*+
CocosDenshionWindowsPhone.dll!Audio::PreloadSoundEffect(const char * pszFilePath, bool isMusic) Line 505 C*+
CocosDenshionWindowsPhone.dll!Audio::PlaySoundEffect Line 288 C*+
CocosDenshionWindowsPhone.dll!CocosDenshion::SimpleAudioEngine::playEffect(const char * pszFilePath, bool bLoop) Line 126 C++

I swear, that I have double, triple checked the file name, messed around with paths and renaming the file and all things I can think of but it still fails to open the file… and the file is definitely in the Assets directory.

Note that it converts it (successfully) from standard ASCII c string to unicode when going from PreloadSoundEffect to Initialize

Any ideas…?




Okay. Two issues here. One is the path is not the path that I was expecting which I found with a lot of experimentation and secondly it seems to only not throw exception on wav files, so I’ve converted my mp3s to wavs and it seems to work.



Am also getting the same error while playing / preloading wav file in WP8, VS2012 Express Edition with Cocos2d-x 2.2 version:

How you get the correct path after experiments?


I was using another version of cocos2dx…

FWIW, Once I got the paths correct it only played audio in Debug.
Release mode did not play audio full stop. The current version of Cocos2d will not build Release mode at all for me and the app store only accepts Release mode apps.

The code looked like…

and the
Path for the file was

… and the audio file was added under Assets folder in the project explorer.

Can you get release build to work with the current version…?



Thanks for reply.

Can you get release build to work with the current version…?
@Regan, I get the release build with Cocos2d-x 2.2 version successfully.
You might miss to set the Dependencies or paths for Release configuration which you have done for Debug configuration.

Finally I found the correct path of audio files.
In solution explorer, the file is at this path “/Assets/Resources/click.wav”; but in fact in the package it is at this path “Install/click.wav”.

This conflict was due to adding assets to Resources folder using drag-n-drop way.
If we add same assets using “Add Existing Items” option which appears while right clicking on the Resources folder, the conflict will be resolved.



Am also getting the same error while preloading wav file in WP8,VS2012 Express Edition with Cocos2d-x 2.2 version:
How do you solve it?


In fact, there is no code change.

Previously my wav file was not at “/Assets/Resources/” in the package.xap build file.
Make sure all assets or wav files are at “/Assets/Resources/” path mainly in package.xap also.
I followed the below steps.

1.Get the backup of all assets anywhere to temp folder
2.Delete all currents assets in Resources filter from solution explorer
3.Copy all backed up assets from temp folder to Resources folder
4.Right click on Resources filter in solution explorer, choose Add Existing Item, and select all assets