sound effects are not playing in my game - windows-phone-8

I am developing a game for windows phone. The target version of game is 7.1 and 7.1 games and apps will be supported on wp8 devices.
Here is my code:
public SoundEffect l1;
public SoundEffectInstance level1sound;
l1 = contentManager.Load<SoundEffect>("sound/level1");
level1sound = l1.CreateInstance();
level1sound.IsLooped = true;
level1sound.Play();
Gaming sounds are working fine in simulator of 7.1 but when I deploy on wp8 device nothing works.
How to fix this issue?

If you develop Silverlight game, you must call FrameworkDispatcher.Update() method in every frame to dispatch messages that are in the XNA Framework message queue

sound file properties should set to soundeffect type

Related

How to load/show OS-specific activity / view from a Cocos2d-x Scene?

I have a cocos2d-x game from which I would like to show an Activity (if the user is using Android) and a ViewController (if the user is using iOS) and then when the user dismisses these views I return to the Cocos2d-x scene that they are in.
Does anyone know of a strategy I could take to accomplish this?
The native views have to be called by native code.
iOS is Objective-c, Android is Java.
The links here should give you some concepts.
For android : http://stnguyen.com/cocos2d-x/call-java-functions-from-cpp.html
For iOS : Call native ObjC classes from cocos2d-x code

NuGet MonoGame WindowsPhone 8.0

I have a problem integrating MonoGame into an existing WindowsPhone8.0 project.
Everything seems to work fine, but when is start the app it's crashing with NullPointerException in MonoGame Framework.
StackTrace:
at MonoGame.Framework.WindowsPhone.WindowsPhoneGameWindow..ctor(Game game)
at MonoGame.Framework.WindowsPhone.WindowsPhoneGamePlatform..ctor(Game game)
at Microsoft.Xna.Framework.GamePlatform.PlatformCreate(Game game)
at Microsoft.Xna.Framework.Game..ctor()
at myApp.Game1..ctor()
at myApp.myPage..ctor()
EDIT:
I have also tried that: link
Based on the stack trace your myPage constructor goes somewhat like this:
_game = new Game1();
The Windows Phone project template, however, does it this way:
_game = XamlGame<Game1>.Create("", this);
The latter version does lots of initialization, for example stores a reference to the XAML page for framework use. The first version crashes because the said initialization is not done, and tries to access null page.

How to use background media player in Windows Phone Silverlight 8.1

I am working on a Windows Phone application for Windows 8.1. I need to use features like Motion classes, Isolated Storage etc. As these features were not supported in Windows Phone 8.1 I went for Windows Phone Silverlight 8.1. Now I have to use BackgroundMediaPlayer in my project and Windows.Media.Playback is not supported in Windows Phone Silverlight 8.1. Is there any possible way by which i can use all the basic API's like:-
-Microsoft.Devices.Sensors
-Microsoft.Xna.Framework
-System.IO.IsolatedStorage-System.Windows.Media.Imaging
and use BackgroundMediaPlayer, Motion classes?? any help will be really useful.
Thanks,
Ekta
Playing Background audio differs in Windows Runtime and Silverlight (Overview). You were trying to use MediaPlayer which:
Minimum supported phone Windows Phone 8.1 [Windows Runtime apps only]
is only for runtime.
As for working with BackgroundAudioPlayer Class in Silverlight 8.1, there is a problem - it won't work. This is a limitation in Silverlight 8.1:
The AudioPlayerAgent and AudioStreamingAgent classes, which supported background audio playback for Windows Phone 8 apps, are not supported in Silverlight 8.1. If you want to support background audio playback, you can continue to use a Windows Phone 8 app or create a Windows Phone Store app, which supports new background audio APIs.
So in this case you will have to write app that target WP8.0 Silverlight or or WP8.1 Store app.
The similar question was here at MSDN forum.
You can achieve that by Creating a new Windows Runtime Component. This is where your entry point for the Audio task will be. The entry point is a class that implements IBackgroundTask. This gives you one method that will be invoked on startup of the Audio task named Run.
In order to keep the Task alive indefinitely you need to keep track of the deferral that exists on the IBackgroundTaskInstance. Placing the deferral in a field for safe keeping will be enough. When the operating system cancels your task you will need to call Complete on this said deferral.
An example of a bare bone implementation of your task should look something like the following
public sealed class AudioPlayer : IBackgroundTask
{
private BackgroundTaskDeferral _deferral;
public void Run(IBackgroundTaskInstance taskInstance)
{
_deferral = taskInstance.GetDeferral();
taskInstance.Canceled += TaskInstance_Canceled;
}
private void TaskInstance_Canceled(IBackgroundTaskInstance sender, BackgroundTaskCancellationReason reason)
{
_deferral.Complete();
}
}
for more Refrence you can go here

how to lock the screen programmatically in windows phone 8?

We can prevent the screen to lock using the below code
PhoneApplicationService.Current.ApplicationIdleMode = IdleDetectionMode.Disabled
and
PhoneApplicationService.Current.UserIdleDetectionMode= IdleDetectionMode.Disabled
but how to lock the screen from my app. Like the below app
http://www.windowsphone.com/en-us/store/app/one-touch-lockscreen/a3b1220b-1f9a-4bf0-93bc-21ed02792279
Thanks in advance
It's pretty hacky. It's not in the official API, so it could stop working at any time, just like the volume control API. Anyway, it you want to do it, you need to use this external method:
[System.Runtime.InteropServices.DllImport("ShellChromeAPI.dll")]
private extern static void Shell_TurnScreenOn(bool value);
For WP8.0 app this needs to be in a Windows Runtime Component (you should reference its output, as the project cannot be referenced).
From what I understand, though, this won't work on WP8.1 devices, so you'll need a separate WP8.1 app and I think it needs to be a XAML (Windows Store) app.
What #yasen wrote is correct.
[DllImport("ShellChromeAPI.dll")]
private extern static void Shell_TurnScreenOn(bool value);
I've tried the following cases:
Runtime 8.1 C# (Passed store certification)
Runtime 8.1 C++ with Runtime Component 8.1 C# (Haven't tried to publish this in store)
Silverlight/DirectX 8.0 C++ (Passed store certification)
Here's the link to my app that's using the last solution mentioned above.
http://www.windowsphone.com/s?appid=38bf5918-025e-4f23-b515-2cac451a84ab
And I've heard about cases in store using Silverlight that supports 8.0 and 8.1.
You can get Screen is locked or not by Windows.Phone.System.SystemProtection.ScreenLocked
but Unfortunately There is no way to lock the screen via code in Windows Phone 7.x or 8.

Exception in launch application in libgdx

LwjglApplicationConfiguration cfg = new LwjglApplicationConfiguration();
cfg.title = "my-gdx-game";
cfg.useGL20 = false;
cfg.width = 480;
cfg.height = 320;
new LwjglApplication(new MyGdxGame(), cfg);
I use this code in my desktop launcher class, but I get GdxRuntimeException: OpenGL is not supported by the video driver.
any help ?
Its probably because:
OpenGL is not supported by your video driver
Libgdx on the desktop requires at least OpenGL 1.5 be supported by your desktop video card (to emulate OpengGL ES 1.x). OpenGL should be included with your OS's graphics card drivers (you should include details about your platform in your question). See the OpenGL Getting Started Wiki for some hints.
See also libGDX Exception in thread "LWJGL Application"