Skip to content

Commit bb557f4

Browse files
wihtout one-time exceptions and in release, seems to move reset media ok
1 parent 1b560f2 commit bb557f4

File tree

4 files changed

+186
-174
lines changed

4 files changed

+186
-174
lines changed

Samples/StyleTransfer/AppViewModel.cs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ private async Task EvaluateVideoFrameAsync()
262262
public async Task StartLiveStream()
263263
{
264264
Debug.WriteLine("StartLiveStream");
265+
await CleanupCameraAsync();
265266

266267
try
267268
{
@@ -290,8 +291,9 @@ public async Task StartLiveStream()
290291

291292
public async Task ChangeLiveStream()
292293
{
293-
await CleanupCameraAsync();
294294
Debug.WriteLine("ChangeLiveStream");
295+
await CleanupCameraAsync();
296+
295297
SaveEnabled = false;
296298

297299
// If webcam hasn't been initialized, bail.
@@ -300,7 +302,11 @@ public async Task ChangeLiveStream()
300302
try
301303
{
302304
// Check that SCI hasn't < 0
303-
if (_appModel.SelectedCameraIndex < 0) _appModel.SelectedCameraIndex = 0;
305+
if (_appModel.SelectedCameraIndex < 0)
306+
{
307+
_appModel.SelectedCameraIndex = 0;
308+
return;
309+
}
304310
_selectedMediaFrameSourceGroup = _mediaFrameSourceGroupList[_appModel.SelectedCameraIndex];
305311

306312
// Create MediaCapture and its settings
@@ -312,6 +318,7 @@ public async Task ChangeLiveStream()
312318
StreamingCaptureMode = StreamingCaptureMode.Video
313319
};
314320
_mediaCapture = new MediaCapture();
321+
Debug.WriteLine("initalized mediacapture");
315322
await _mediaCapture.InitializeAsync(settings);
316323
displayRequest.RequestActive();
317324

@@ -398,7 +405,12 @@ private async Task CleanupCameraAsync()
398405
{
399406
if (isPreviewing)
400407
{
401-
await _mediaCapture.StopPreviewAsync();
408+
try
409+
{
410+
await _mediaCapture.StopPreviewAsync();
411+
}
412+
catch (Exception e) { Debug.WriteLine("CleanupCamera: " + e.Message); }
413+
402414
isPreviewing = false;
403415
}
404416
await DispatcherHelper.RunAsync(() =>
@@ -416,11 +428,7 @@ await DispatcherHelper.RunAsync(() =>
416428
m.Dispose();
417429
});
418430
}
419-
if (videoEffect != null)
420-
{
421-
videoEffect = null;
422-
}
423-
if (videoEffectDefinition != null) videoEffectDefinition = null;
431+
424432
}
425433

426434
catch (Exception ex)

Samples/StyleTransfer/StyleTransfer.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@
217217
</ItemGroup>
218218
<ItemGroup>
219219
<PackageReference Include="Microsoft.AI.MachineLearning">
220-
<Version>1.3.0</Version>
220+
<Version>1.3.1-dev-20200711-0122-00cc8041c</Version>
221221
</PackageReference>
222222
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
223223
<Version>6.2.10</Version>

0 commit comments

Comments
 (0)