简体   繁体   中英

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM