ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent
luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Typi non habent claritatem insitam; est
usus legentis in iis qui facit eorum claritatem.
-
diff --git a/Samples/AnimationLibrary/js/js/samplePage.js b/Samples/AnimationLibrary/js/js/samplePage.js
index 2ac2e5c55d..14c327fe5c 100644
--- a/Samples/AnimationLibrary/js/js/samplePage.js
+++ b/Samples/AnimationLibrary/js/js/samplePage.js
@@ -3,22 +3,23 @@
(function () {
"use strict";
+ var systemNavigationManager = Windows.UI.Core.SystemNavigationManager.getForCurrentView();
+
WinJS.UI.Pages.define("/html/samplePage.html", {
ready: function (element, options) {
- returnButton.addEventListener("click", transitionBetweenPages, false);
-// rootGrid.style.overflow= "auto";
-// content.style.overflow = "visible";
+ systemNavigationManager.addEventListener("backrequested", backRequested);
+ systemNavigationManager.appViewBackButtonVisibility = Windows.UI.Core.AppViewBackButtonVisibility.visible;
// Run enter page animation to animate in the page that has just been loaded
WinJS.UI.Animation.enterPage([samplePageHeader, samplePageSection1, samplePageSection2], null);
},
unload: function () {
-// rootGrid.style.overflow = "visible";
-// content.style.overflow = "auto";
+ systemNavigationManager.removeEventListener("backrequested", backRequested);
+ systemNavigationManager.appViewBackButtonVisibility = Windows.UI.Core.AppViewBackButtonVisibility.collapsed;
}
});
- function transitionBetweenPages() {
+ function backRequested() {
// When navigating away from this page, run exit page animation on current page, then navigate to new page
WinJS.UI.Animation.exitPage([samplePageHeader, samplePageSection1, samplePageSection2], null).done(
function () {
diff --git a/Samples/AnimationMetrics/README.md b/Samples/AnimationMetrics/README.md
index 7a2a40fb4f..45f9c24568 100644
--- a/Samples/AnimationMetrics/README.md
+++ b/Samples/AnimationMetrics/README.md
@@ -1,6 +1,6 @@
# Animation metrics sample
diff --git a/Samples/AppServices/README.md b/Samples/AppServices/README.md
index 932df93ccb..007003b88e 100644
--- a/Samples/AppServices/README.md
+++ b/Samples/AppServices/README.md
@@ -1,6 +1,6 @@
# App services sample
diff --git a/Samples/ApplicationData/README.md b/Samples/ApplicationData/README.md
index 1a8874d6cb..3ac3800dd6 100644
--- a/Samples/ApplicationData/README.md
+++ b/Samples/ApplicationData/README.md
@@ -1,6 +1,6 @@
# Application data sample
diff --git a/Samples/ApplicationResources/README.md b/Samples/ApplicationResources/README.md
index 4b09c6d298..5065a3d6ad 100644
--- a/Samples/ApplicationResources/README.md
+++ b/Samples/ApplicationResources/README.md
@@ -1,6 +1,6 @@
# Application resources and localization sample
diff --git a/Samples/Appointments/README.md b/Samples/Appointments/README.md
index 808b205d57..5429149713 100644
--- a/Samples/Appointments/README.md
+++ b/Samples/Appointments/README.md
@@ -1,6 +1,6 @@
# Appointment calendar sample
diff --git a/Samples/AssociationLaunching/README.md b/Samples/AssociationLaunching/README.md
index 3334bb63e1..7062b4572c 100644
--- a/Samples/AssociationLaunching/README.md
+++ b/Samples/AssociationLaunching/README.md
@@ -1,6 +1,6 @@
# Association launching sample
diff --git a/Samples/AudioCategory/README.md b/Samples/AudioCategory/README.md
index 22ef40a5ca..b6c509a3af 100644
--- a/Samples/AudioCategory/README.md
+++ b/Samples/AudioCategory/README.md
@@ -1,6 +1,6 @@
# Audio categories sample
diff --git a/Samples/AudioCreation/README.md b/Samples/AudioCreation/README.md
index 760ba7ccd0..a557497401 100644
--- a/Samples/AudioCreation/README.md
+++ b/Samples/AudioCreation/README.md
@@ -1,6 +1,6 @@
# AudioGraph sample
diff --git a/Samples/BackButton/README.md b/Samples/BackButton/README.md
index fb4b777c8c..b96602844f 100644
--- a/Samples/BackButton/README.md
+++ b/Samples/BackButton/README.md
@@ -1,6 +1,6 @@
# Back Button Sample
diff --git a/Samples/BackgroundAudio/README.md b/Samples/BackgroundAudio/README.md
index aeedbb3dd1..e381d25987 100644
--- a/Samples/BackgroundAudio/README.md
+++ b/Samples/BackgroundAudio/README.md
@@ -1,6 +1,6 @@
# Background audio sample
diff --git a/Samples/BackgroundAudio/cs/BackgroundAudio/Scenario1.xaml.cs b/Samples/BackgroundAudio/cs/BackgroundAudio/Scenario1.xaml.cs
index 1288991246..7d205116e1 100644
--- a/Samples/BackgroundAudio/cs/BackgroundAudio/Scenario1.xaml.cs
+++ b/Samples/BackgroundAudio/cs/BackgroundAudio/Scenario1.xaml.cs
@@ -39,7 +39,7 @@ public sealed partial class Scenario1 : Page
#region Private Fields and Properties
private MainPage rootPage;
private AutoResetEvent backgroundAudioTaskStarted;
- private bool isMyBackgroundTaskRunning = false;
+ private bool _isMyBackgroundTaskRunning = false;
private Dictionary albumArtCache = new Dictionary();
const int RPC_S_SERVER_UNAVAILABLE = -2147023174; // 0x800706BA
@@ -52,7 +52,7 @@ private bool IsMyBackgroundTaskRunning
{
get
{
- if (isMyBackgroundTaskRunning)
+ if (_isMyBackgroundTaskRunning)
return true;
string value = ApplicationSettingsHelper.ReadResetSettingsValue(ApplicationSettingsConstants.BackgroundTaskState) as string;
@@ -64,13 +64,13 @@ private bool IsMyBackgroundTaskRunning
{
try
{
- isMyBackgroundTaskRunning = EnumHelper.Parse(value) == BackgroundTaskState.Running;
+ _isMyBackgroundTaskRunning = EnumHelper.Parse(value) == BackgroundTaskState.Running;
}
catch(ArgumentException)
{
- isMyBackgroundTaskRunning = false;
+ _isMyBackgroundTaskRunning = false;
}
- return isMyBackgroundTaskRunning;
+ return _isMyBackgroundTaskRunning;
}
}
}
@@ -87,20 +87,28 @@ private MediaPlayer CurrentPlayer
get
{
MediaPlayer mp = null;
+ int retryCount = 2;
- try
+ while (mp == null && --retryCount >= 0)
{
- mp = BackgroundMediaPlayer.Current;
- }
- catch (Exception ex)
- {
- if (ex.HResult == RPC_S_SERVER_UNAVAILABLE)
+ try
{
- // The foreground app uses RPC to communicate with the background process.
- // If the background process crashes or is killed for any reason RPC_S_SERVER_UNAVAILABLE
- // is returned when calling Current.
- ResetAfterLostBackground();
- StartBackgroundAudioTask();
+ mp = BackgroundMediaPlayer.Current;
+ }
+ catch (Exception ex)
+ {
+ if (ex.HResult == RPC_S_SERVER_UNAVAILABLE)
+ {
+ // The foreground app uses RPC to communicate with the background process.
+ // If the background process crashes or is killed for any reason RPC_S_SERVER_UNAVAILABLE
+ // is returned when calling Current. We must restart the task, the while loop will retry to set mp.
+ ResetAfterLostBackground();
+ StartBackgroundAudioTask();
+ }
+ else
+ {
+ throw;
+ }
}
}
@@ -114,12 +122,13 @@ private MediaPlayer CurrentPlayer
}
///
- /// The background task did exist, but it has disappeared. Put the foreground back into an initial state.
+ /// The background task did exist, but it has disappeared. Put the foreground back into an initial state. Unfortunately,
+ /// any attempts to unregister things on BackgroundMediaPlayer.Current will fail with the RPC error once the background task has been lost.
///
private void ResetAfterLostBackground()
{
BackgroundMediaPlayer.Shutdown();
- isMyBackgroundTaskRunning = false;
+ _isMyBackgroundTaskRunning = false;
backgroundAudioTaskStarted.Reset();
prevButton.IsEnabled = true;
nextButton.IsEnabled = true;
@@ -136,6 +145,10 @@ private void ResetAfterLostBackground()
{
throw new Exception("Failed to get a MediaPlayer instance.");
}
+ else
+ {
+ throw;
+ }
}
}
@@ -220,7 +233,7 @@ protected override void OnNavigatedTo(NavigationEventArgs e)
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
- if(isMyBackgroundTaskRunning)
+ if(_isMyBackgroundTaskRunning)
{
RemoveMediaPlayerEventHandlers();
ApplicationSettingsHelper.SaveSettingsValue(ApplicationSettingsConstants.BackgroundTaskState, BackgroundTaskState.Running.ToString());
@@ -500,9 +513,9 @@ private void UpdateTransportControls(MediaPlayerState state)
///
private void RemoveMediaPlayerEventHandlers()
{
- CurrentPlayer.CurrentStateChanged -= this.MediaPlayer_CurrentStateChanged;
try
{
+ BackgroundMediaPlayer.Current.CurrentStateChanged -= this.MediaPlayer_CurrentStateChanged;
BackgroundMediaPlayer.MessageReceivedFromBackground -= BackgroundMediaPlayer_MessageReceivedFromBackground;
}
catch (Exception ex)
@@ -536,6 +549,10 @@ private void AddMediaPlayerEventHandlers()
// Internally MessageReceivedFromBackground calls Current which can throw RPC_S_SERVER_UNAVAILABLE
ResetAfterLostBackground();
}
+ else
+ {
+ throw;
+ }
}
}
diff --git a/Samples/BackgroundSensors/README.md b/Samples/BackgroundSensors/README.md
index 9a650d1038..4984948d1f 100644
--- a/Samples/BackgroundSensors/README.md
+++ b/Samples/BackgroundSensors/README.md
@@ -1,6 +1,6 @@
# Background sensors sample
diff --git a/Samples/BackgroundTask/README.md b/Samples/BackgroundTask/README.md
index 242ee585f7..00d222ec93 100644
--- a/Samples/BackgroundTask/README.md
+++ b/Samples/BackgroundTask/README.md
@@ -1,6 +1,6 @@
# Background task sample
diff --git a/Samples/BackgroundTransfer/README.md b/Samples/BackgroundTransfer/README.md
index d208927b96..abedbadbaa 100644
--- a/Samples/BackgroundTransfer/README.md
+++ b/Samples/BackgroundTransfer/README.md
@@ -1,6 +1,6 @@
# Background transfer sample
diff --git a/Samples/BarcodeScanner/README.md b/Samples/BarcodeScanner/README.md
index b058f123ae..a29e2d597d 100644
--- a/Samples/BarcodeScanner/README.md
+++ b/Samples/BarcodeScanner/README.md
@@ -1,6 +1,6 @@
# Barcode scanner sample
diff --git a/Samples/Barometer/README.md b/Samples/Barometer/README.md
index 144815c606..b389da32de 100644
--- a/Samples/Barometer/README.md
+++ b/Samples/Barometer/README.md
@@ -1,6 +1,6 @@
# Barometer sample
diff --git a/Samples/BasicFaceDetection/README.md b/Samples/BasicFaceDetection/README.md
index 1bbe97b9f1..501506e7ef 100644
--- a/Samples/BasicFaceDetection/README.md
+++ b/Samples/BasicFaceDetection/README.md
@@ -1,6 +1,6 @@
# Basic face detection sample
diff --git a/Samples/BasicFaceTracking/README.md b/Samples/BasicFaceTracking/README.md
index 0f2e028e6f..0f23f3fbd0 100644
--- a/Samples/BasicFaceTracking/README.md
+++ b/Samples/BasicFaceTracking/README.md
@@ -1,6 +1,6 @@
# Basic face tracking sample
diff --git a/Samples/BasicInput/README.md b/Samples/BasicInput/README.md
index acf5f437b6..0ac9eaadd4 100644
--- a/Samples/BasicInput/README.md
+++ b/Samples/BasicInput/README.md
@@ -1,6 +1,6 @@
# Basic input sample
diff --git a/Samples/BasicMediaCasting/README.md b/Samples/BasicMediaCasting/README.md
index 3deefcd96e..425d59faf3 100644
--- a/Samples/BasicMediaCasting/README.md
+++ b/Samples/BasicMediaCasting/README.md
@@ -1,6 +1,6 @@
# Basic media casting sample
diff --git a/Samples/BluetoothAdvertisement/README.md b/Samples/BluetoothAdvertisement/README.md
index 5b79bfa7be..3d5fea1948 100644
--- a/Samples/BluetoothAdvertisement/README.md
+++ b/Samples/BluetoothAdvertisement/README.md
@@ -1,6 +1,6 @@
# Bluetooth advertisement sample
diff --git a/Samples/BluetoothRfcommChat/README.md b/Samples/BluetoothRfcommChat/README.md
index e30571c7e3..c2594a3a7e 100644
--- a/Samples/BluetoothRfcommChat/README.md
+++ b/Samples/BluetoothRfcommChat/README.md
@@ -1,6 +1,6 @@
# Bluetooth RFCOMM chat sample
diff --git a/Samples/Calendar/README.md b/Samples/Calendar/README.md
index 6e71bb0d22..a117e83cb9 100644
--- a/Samples/Calendar/README.md
+++ b/Samples/Calendar/README.md
@@ -1,6 +1,6 @@
# Calendar sample
diff --git a/Samples/CameraFaceDetection/README.md b/Samples/CameraFaceDetection/README.md
index c64a85e1f2..b4d6ee8bd2 100644
--- a/Samples/CameraFaceDetection/README.md
+++ b/Samples/CameraFaceDetection/README.md
@@ -1,6 +1,6 @@
# Camera face detection sample
diff --git a/Samples/CameraGetPreviewFrame/README.md b/Samples/CameraGetPreviewFrame/README.md
index a5ded7c7b1..148838539b 100644
--- a/Samples/CameraGetPreviewFrame/README.md
+++ b/Samples/CameraGetPreviewFrame/README.md
@@ -1,6 +1,6 @@
# Camera preview frame sample
diff --git a/Samples/CameraHdr/README.md b/Samples/CameraHdr/README.md
index 3220749099..89342954b1 100644
--- a/Samples/CameraHdr/README.md
+++ b/Samples/CameraHdr/README.md
@@ -1,6 +1,6 @@
# High dynamic range sample
diff --git a/Samples/CameraManualControls/README.md b/Samples/CameraManualControls/README.md
index febc74b7a2..c07f23ff47 100644
--- a/Samples/CameraManualControls/README.md
+++ b/Samples/CameraManualControls/README.md
@@ -1,6 +1,6 @@
# Manual camera controls sample
diff --git a/Samples/CameraManualControls/cs/MainPage.xaml.cs b/Samples/CameraManualControls/cs/MainPage.xaml.cs
index 8a40b9c21e..5f69d2c861 100644
--- a/Samples/CameraManualControls/cs/MainPage.xaml.cs
+++ b/Samples/CameraManualControls/cs/MainPage.xaml.cs
@@ -60,6 +60,9 @@ public sealed partial class MainPage : Page
// For listening to media property changes
private readonly SystemMediaTransportControls _systemMediaControls = SystemMediaTransportControls.GetForCurrentView();
+ // Access to the Back button
+ private readonly SystemNavigationManager _systemNavigationManager = SystemNavigationManager.GetForCurrentView();
+
// MediaCapture and its state variables
private MediaCapture _mediaCapture;
private bool _isInitialized;
@@ -608,7 +611,6 @@ private void RegisterEventHandlers()
if (ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
{
HardwareButtons.CameraPressed += HardwareButtons_CameraPressed;
- HardwareButtons.BackPressed += HardwareButtons_BackPressed;
}
// If there is an orientation sensor present on the device, register for notifications
@@ -622,32 +624,21 @@ private void RegisterEventHandlers()
_displayInformation.OrientationChanged += DisplayInformation_OrientationChanged;
_systemMediaControls.PropertyChanged += SystemMediaControls_PropertyChanged;
+ _systemNavigationManager.BackRequested += SystemNavigationManager_BackRequested;
}
- private void HardwareButtons_BackPressed(object sender, BackPressedEventArgs e)
+ private void SystemNavigationManager_BackRequested(object sender, BackRequestedEventArgs e)
{
- // Back button exits single control mode
if (_singleControlMode)
{
// Exit single control mode
- _singleControlMode = false;
-
- // If in single control mode, hide all child buttons (except for the sender). Otherwise show all buttons.
- foreach (var button in ScenarioControlStackPanel.Children)
- {
- if (button is Button && button != sender)
- {
- button.Visibility = Visibility.Visible;
- }
- }
-
- // Hide the container control for manual input
- ManualControlsGrid.Visibility = Visibility.Collapsed;
+ SetSingleControl(null);
e.Handled = true;
}
}
+
///
/// Unregisters event handlers for hardware buttons and orientation sensors
///
@@ -656,7 +647,6 @@ private void UnregisterEventHandlers()
if (ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
{
HardwareButtons.CameraPressed -= HardwareButtons_CameraPressed;
- HardwareButtons.BackPressed -= HardwareButtons_BackPressed;
}
if (_orientationSensor != null)
@@ -666,6 +656,7 @@ private void UnregisterEventHandlers()
_displayInformation.OrientationChanged -= DisplayInformation_OrientationChanged;
_systemMediaControls.PropertyChanged -= SystemMediaControls_PropertyChanged;
+ _systemNavigationManager.BackRequested -= SystemNavigationManager_BackRequested;
}
///
@@ -912,24 +903,35 @@ private void UpdateButtonOrientation()
#region Manual controls setup
- private void ManualControlButton_Tapped(object sender, TappedRoutedEventArgs e)
+ // If activeButton = null, then exit single control mode.
+ private void SetSingleControl(object activeButton)
{
- // Toggle single control mode
- _singleControlMode = !_singleControlMode;
+ _singleControlMode = (activeButton != null);
- // If in single control mode, hide all manual control buttons (except for the sender, which was tapped), otherwise show all buttons
- foreach (var button in ScenarioControlStackPanel.Children)
+ // If in single control mode, hide all manual control buttons (except for the active button).
+ // if not in single control mode, then show all the buttons which are supported.
+ foreach (var button in ScenarioControlStackPanel.Children.OfType