How to navigate to Windows Phone 8 start screen using C# - c#

I have built a very basic sound board app by following video tutorial series on channel 9 [http://channel9.msdn.com/Series/Windows-Phone-8-Development-for-Absolute-Beginners]. Each page in the app displays a list of sound tiles, which on tap plays associated sound. I have extended the app to allow user to tile the individual sound to phone's start screen. Everything works fine upto this point.
Now whenever user taps the sound from start screen, I want app tile to just play the sound, however its navigating into the application at the moment. I have raised similar question on channel 9 and the video series author suggested me that its possible by calling NavigationService.GoBack method on OnNavigatedTo event. I tried that, however I am getting exception with message 'Cannot go back when CanGoBack is false'. Here is the channel 9 thread - http://channel9.msdn.com/Series/Windows-Phone-8-Development-for-Absolute-Beginners/Part-23-Testing-and-Submitting-to-the-Store
Appreciate if someone helps me to resolve the issue.
Entire source code of my app is available on GitHub at https://github.com/PrasadHonrao/WindowsPhone8/tree/master/SoundJabber
Thanks.

To programmatically exit an application, you can call:
Application.Current.Terminate();
Unfortunately, it will work only on Windows Phone 8, this method isn't available on Windows Phone 7.

You can't use navigationService.GoBack when you don't have navigation history.
When you are in your main page and you want to exit your application you can use NavigationService.RemoveBackEntry() for remove navigation history.
If you want play sound for a specifique user.Create Model ou uri sound as parameter.
For information:
when you use Application.Current.Terminate();.You don't pass in your app.cs.

the simplest you can do is Application.Current.Terminate();

Related

Close splash screen in Hololens 2 with unity

I am a new in Hololens 2 and I build some Unity sample on it.
When start application, it would placed a white box like that.
When stop application, the white box still on here and I need to click X to close it.
I have searched about that, it seem like about uwp application lifecycle?
Is there any method to close it with C# when I quit my application.
Thanks in advance for any suggestions.
It is by design and can only be closed manually, every app starts in mixed reality by placing an app tile in the Windows Mixed Reality home and these tiles persist and stay at their placed location. For more information please see:App model
In addition to this, you can add a custom holographic splash screen for the app, please refer to this link:Holographic splash screen

Windows Phone turn flash on in background

I am working on a tools app and I need a way to turn on the camera flash when I click a tile, then keep it on in the background and turn it off once I click the tile again.
I don't need any help with the tile yet all I want to know is what I can do to turn on the flash and then keep it on. All the examples I have seen thus far simply pretend to be a camera and then turn the flash on.
Do you know of anything?
PS. I am planning on making this for WP 7 and 8 but if you know of a way that will on work on WP 8 that will also help me a lot.
The simple answer is no.
While the app is running, you can control the camera and turn on the flash. But as soon as you exit the app (Back button) or the app is suspended (due to a phone call or by pressing the Start button), the use of the camera is suspended.
Windows Phone does have Background Agents but these are very limited and do not allow access to the camera API at all (and many other APIs).

Implementing playlists with songs from phone storage [windows phone]

I have been struggling with an issue with my media player windows phone (7) application. The problem is that I can't seem to implement playlists.
What I want to do is play songs from the media library. This article seems pointless.
I've tried getting into the SongCollection class and figure out how to create more of these things. It appears to be impossible (no constructor, can't cast it, can't inherit it).
After that I tried getting an object on the process running the background audio agent that existed in my app (until I discovered it was redundant), and feed the media player one song at a time.
Problem is, I don't know when the media player stopped playing. It works ok as long as my app is in the foreground, but when it is not, everything stops working, only the media player keeps going.
Is there a way I haven't figured out? In the article above they suggest there is a link between the Zune Media Queue, which I presume is the MediaPlayer.Queue property, and various things I can implement, but I just can't figure a way to make it go.
You should give up since building your own media player is an impossible mission (been there, done that). You cannot create playlists or edit any information, you cannot replace default event handlers for on-screen music controls, you don't get events for music change in your application unless it is currently running.
Basically, it is really limited in what you can do right now and the situation isn't much better with WP8.
I hope that it will be less read-only by the time we get Windows Phone 9.
Take a look at the UWP samples from Microsoft:
https://github.com/Microsoft/Windows-universal-samples
The sample contains play/pause/playlists explanation.
This was already possible in Windows phone 7.5/8/8.1

Disable Application from sleeping in Windows 8 Metro

I am working on an app which displays videos and am running into an issue where the machine goes to sleep after hitting the sleep time limit while a video is playing. Is there a way to disable this behavior in a Windows 8 Metro application?
You should use the DisplayRequest class, specifically DisplayRequest.RequestActive for this purpose. You must also remember to call DisplayRequest.RequestRelease once you are done to allow the display to sleep, for example, if you are not actively playing the movie, or in a menu screen, etc.

How to remove volume controls on lock screen in WP7?

When you stop your music which is playing in the music player, it doesn't really stop it. It just pauses it, as you are still able to see the music controls after you lock the screen. I want to remove the volume controls (rewind,play,forward) buttons which appear on the locked screen using the code behind. This has already been achieved by an existing app on the marketplace Stop the Music!. I have gone through this page, but still I am not able to understand how they are able to do so.
Is there anyway to achieve this??
Nice question, after some trial&error testing I've actually found out, how to remove the Music player from volume controls:
You need to add into your app empty file with .wma extension and set the build action as "Content", for instance "empty.wma" into the app root folder.
To stop the media playback and remove the media player just create dummy Song object and try to play it like this:
Song s = Song.FromUri("empty", new Uri("empty.wma", UriKind.Relative));
MediaPlayer.Play(s);
And that's all, because the file is invalid music file, nothing is playing and even the previous Music player has been removed.
Note I've tested this on Windows Phone 8 device with GDR3 update. Not sure, if it works as well on Windows Phone 7.5.
You don't need to do that now. Windows Phone 7.8 now have the music control as a popup when pressed volumn button on devices.

Categories

Resources