Presentation is loading. Please wait.

Presentation is loading. Please wait.

Camera, Media and Audio in Windows Phone 8.1

Similar presentations


Presentation on theme: "Camera, Media and Audio in Windows Phone 8.1"— Presentation transcript:

1 Camera, Media and Audio in Windows Phone 8.1

2 In this module… Opening, editing and saving photos
Loading or taking photo with the File Open Picker, saving with the File Save Picker Editing with the Nokia Imaging SDK Capturing and Screen Recording Basic capturing of photos and videos Advanced capturing with the new VariablePhotoSequenceCapture Screen recording with the new ScreenCapture API Video Editing Using the new MediaComposition API Background Audio Using the new MediaPlayer API

3 Photo Editing

4 Getting a photo Where’s the CameraCaptureUI?
11/17/2018 Getting a photo Where’s the CameraCaptureUI? Windows CameraCaptureUI is not available on Phone Windows Phone 8 PhotoChooserTask and CameraCaptureTask still work for Silverlight 8.1, but not for Windows Phone XAML-based apps FileOpenPicker is the new PhotoChooserTask Picking single or multiple media files, not only photos Taking photo or video with Windows Phone’s built-in camera UI Covers most scenarios of the CameraCaptureUI as well Available for Silverlight 8.1 and Windows Phone XAML For details, see: Building Apps for Windows Phone 8.1 Jump Start: (13) Sharing © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

5 Getting or storing media files
11/17/2018 Getting or storing media files Full media library I/O access! Read and write access of photos, videos, etc. with UI via FileOpenPicker and FileSavePicker Read and write access of photos, videos, etc. without UI via KnownFolders.VideosLibrary, KnownFolders.PicturesLibrary, KnownFolders… Including transparent access to data stored on SD card Capability declaration needed in Package.appxmanifest: <Capability Name="videosLibrary" /> ... Available for Silverlight 8.1 and WinRT apps © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

6 Editing photos Nokia Imaging SDK WriteableBitmapEx
11/17/2018 Editing photos Nokia Imaging SDK Easy to use imaging SDK from Nokia for free Lots of features and samples 50+ filters and effects Crop, resize, rotate Very fast and efficient Real-time manipulation Available for Silverlight 8.1, WinRT Phone and Windows apps WriteableBitmapEx Open source library with helpful extension methods Available for Silverlight 8.1, WinRT Phone, Windows apps, … © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

7 Editing a photo with the Nokia Imaging SDK
11/17/2018 Editing a photo with the Nokia Imaging SDK // Create NOK Imaging SDK effects pipeline and run it var imageStream = new BitmapImageSource(image.AsBitmap()); using (var effect = new FilterEffect(imageStream)) {      // Define the filters list var filter = new AntiqueFilter();     effect.Filters = new[] { filter };     // Render the filtered image to a WriteableBitmap.     var renderer = new WriteableBitmapRenderer(effect, editedBitmap);     editedBitmap = await renderer.RenderAsync();     editedBitmap.Invalidate();     // Show image in Xaml Image control     Image.Source = editedBitmap; } © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

8 11/17/2018 Demo PhotoEditing © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

9 Capturing and Screen Recording
11/17/2018 Capturing and Screen Recording © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

10 Basic Capturing Windows.Media.Capture
11/17/2018 Basic Capturing Windows.Media.Capture Windows Phone 8.0 provided Windows.Phone.Media.Capture with PhotoCaptureDevice and AudioVideoCaptureDevice for photo, audio and video recording with real-time preview Windows Phone 8.1 MediaCapture from Windows.Media.Capture API replaces the Windows.Phone.Media.Capture API Supports low lag photos (burst mode) Mostly common API for Windows and Phone apps (WinRT and Silverlight 8.1) with a couple of phone-only additions Rene Schulte Face Lens © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

11 Basic Capturing Showing the camera stream in your Xaml UI
11/17/2018 Basic Capturing Showing the camera stream in your Xaml UI Using the CaptureElement in Windows XAML-based apps Using the VideoBrush in Silverlight 8.1 apps MediaCapturePreviewSink for camera preview stream from MediaCapture API using Microsoft.Devices for new VideoBrush.SetSource extension to connect MediaCapturePreviewSink with VideoBrush Real-time parameter control Audio/VideoDeviceController to change parameters like focus, zoom, exposure, RegionOfInterest. … Required capabilities <Capability Name=“webcam" /> <Capability Name=“microphone" /> © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

12 Implementing a Capturing Solution

13 Initializing MediaCapture
11/17/2018 Initializing MediaCapture Windows and Windows Phone XAML Windows Phone Silverlight 8.1 // Create MediaCapture and init mediaCapture = new MediaCapture(); await mediaCapture.InitializeAsync(); // Interop between new MediaCapture API and SL 8.1 to show // the preview in SL XAML as Rectangle.Fill var previewSink = new MediaCapturePreviewSink(); var videoBrush = new VideoBrush(); videoBrush.SetSource(previewSink); PreviewElement.Fill = videoBrush;  // Find the supported preview size var vdc = mediaCapture.VideoDeviceController; var availableMediaStreamProperties = vdc.GetAvailableMediaStreamProperties(MediaStreamType.VideoPreview); // More LINQ selection happens here in the demo to find closest format var previewFormat = availableMediaStreamProperties.FirstOrDefault(); // Start Preview stream await  vdc.SetMediaStreamPropertiesAsync(MediaStreamType.VideoPreview, previewFormat); await mediaCapture.StartPreviewToCustomSinkAsync( new MediaEncodingProfile { Video = previewFormat }, previewSink); // Create MediaCapture and init mediaCapture = new MediaCapture(); await mediaCapture.InitializeAsync(); // Assign to Xaml CaptureElement.Source and start preview PreviewElement.Source = mediaCapture; await mediaCapture.StartPreviewAsync(); © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

14 11/17/2018 Capturing a photo public async Task CapturePhoto() {     // Create photo encoding properties as JPEG and set the size that should be used for capturing     var imgEncodingProperties = ImageEncodingProperties.CreateJpeg();     imgEncodingProperties.Width = 640;     imgEncodingProperties.Height = 480;     // Create new unique file in the pictures library and capture photo into it     var photoStorageFile = await KnownFolders.PicturesLibrary.CreateFileAsync("photo.jpg",  CreationCollisionOption.GenerateUniqueName);     await mediaCapture.CapturePhotoToStorageFileAsync(imgEncodingProperties, photoStorageFile); } © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

15 Supporting hardware camera buttons
11/17/2018 Supporting hardware camera buttons HardwareButtons.CameraHalfPressed += HardwareButtonsOnCameraHalfPressed; HardwareButtons.CameraPressed += HardwareButtonsOnCameraPressed; private async void HardwareButtonsOnCameraHalfPressed(object sender, CameraEventArgs cameraEventArgs) {     await mediaCapture.VideoDeviceController.FocusControl.FocusAsync(); } private async void HardwareButtonsOnCameraPressed(object sender, CameraEventArgs cameraEventArgs) {     await CapturePhoto(); } © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

16 Recording and playing a video
11/17/2018 Recording and playing a video public async Task StartVideoRecording() {     // Create video encoding profile as MP4      var videoEncodingProperties = MediaEncodingProfile.CreateMp4(VideoEncodingQuality.Vga);                  // Create new unique file in the videos library and record video!      var videoStorageFile = await KnownFolders.VideosLibrary.CreateFileAsync("video.mp4",  CreationCollisionOption.GenerateUniqueName);     await mediaCapture.StartRecordToStorageFileAsync(videoEncodingProperties, videoStorageFile); } public async Task StopVideoRecording() {     await mediaCapture.StopRecordAsync(); // Start playback in MediaElement var videoFileStream = await videoFile.OpenReadAsync(); PlaybackElement.SetSource(videoFileStream, videoFile.ContentType); } © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

17 Changing camera parameters
11/17/2018 Changing camera parameters var zoomControl = mediaCapture.VideoDeviceController.Zoom; if (zoomControl != null && zoomControl.Capabilities.Supported) {     SliderZoom.IsEnabled = true;     SliderZoom.Maximum = zoomControl.Capabilities.Max;     SliderZoom.Minimum = zoomControl.Capabilities.Min;     SliderZoom.StepFrequency = zoomControl.Capabilities.Step;     SliderZoom currentValue;     if (zoomControl.TryGetValue(out currentValue))     {         SliderZoom.Value = currentValue;     }     SliderZoom.ValueChanged += (s, e) => zoomControl.TrySetValue(SliderZoom.Value); } else {     SliderZoom.IsEnabled = false; } © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

18 Demo BasicCapturing 11/17/2018
© 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

19 Advanced Capturing Phone is the better point ‘n’ shoot
11/17/2018 Advanced Capturing Phone is the better point ‘n’ shoot Windows.Media.Capture.Core ships some phone-only APIs Available for Silverlight 8.1 and WinRT-based phone apps VariablePhotoSequenceCapture Burst shot with variable parameters for each photo Enables HDR and more cool scenarios without tripod Just add the desired parameters for each photo via the VariablePhotoSequenceController.DesiredFrameControllers then vpc = await PrepareVariablePhotoSequenceCaptureAsync() and finally start sequence capturing vpc.StartAsync() © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

20 Screen Capturing Another gem ScreenCapture
11/17/2018 Screen Capturing Another gem Windows.Media.Capture also provides a new phone-exclusive API to record the current screen ScreenCapture Just route the current screen as input for the MediaCapture Automatically asks for user approval upon first usage Personal information like notifications or DRM content is left out Super easy to use Useful for bug reporting Or recording progress in games Or Replay functionality Or … © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

21 Initializing and running ScreenCapture
11/17/2018 Initializing and running ScreenCapture // Wire up current screen as input for the MediaCapture var screenCapture = ScreenCapture.GetForCurrentView(); mediaCapture = new MediaCapture(); await mediaCapture.InitializeAsync(new MediaCaptureInitializationSettings {     VideoSource = screenCapture.VideoSource,     AudioSource = screenCapture.AudioSource, }); // Create video encoding profile as MP4  var videoEncodingProperties = MediaEncodingProfile.CreateMp4(VideoEncodingQuality.Vga); // Create new unique file in the videos library and record video!  var videoStorageFile = await KnownFolders.VideosLibrary.CreateFileAsync("screenrecording.mp4",  CreationCollisionOption.GenerateUniqueName); await mediaCapture.StartRecordToStorageFileAsync(videoEncodingProperties, videoStorageFile); © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

22 Demo ScreenRecording 11/17/2018
© 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

23 Video Editing

24 Video Editing Windows.Media.Editing MediaComposition
11/17/2018 Video Editing Windows.Media.Editing Another new phone-only API for easy video editing Enables simple scenarios like video trimming or even complex timeline editing applications Available for Silverlight 8.1 and WinRT-based phone apps MediaComposition Combination of source audio and video MediaClips MediaClip can be trimmed by begin, end and volume changed Also supports Media Foundation Transforms effects Additional background music can be added Playback of the composition result via MediaElement Rendering of the composed video result to a StorageFile Built-In persistence support (load and save MediaComposition) © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

25 Implementing a simple video editor

26 Initializing MediaComposition and adding Clips
11/17/2018 Initializing MediaComposition and adding Clips mediaComposition = new MediaComposition(); foreach (StorageFile videoFile in videoFiles) {     // Create Clip and add to composition     var clip = await MediaClip.CreateFromFileAsync(videoFile);     mediaComposition.Clips.Add(clip);     // Create thumbnail to show as placeholder in an UI ListView     var thumbnail = await videoFile.GetThumbnailAsync(ThumbnailMode.VideosView);     var image = new BitmapImage();     image.SetSource(thumbnail);     // Add to a viewmodel used as ItemsSource for a ListView of clips     videoClips.Add(new VideoClip(clip, image, videoFile.Name)); } © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

27 Trimming and adding background music
11/17/2018 Trimming and adding background music // Trimming. Skip 1 second from the beginning of the clip and 2 from the end var clipVm = videoClips.SelectedClip; clipVm.Clip.TrimTimeFromStart = TimeSpan.FromSeconds(1); clipVm.Clip.TrimTimeFromEnd = clipVm.Clip.OriginalDuration.Subtract(TimeSpan.FromSeconds(2)); // Add MP3 as background which was deployed together with the AppX package var file = await Package.Current.InstalledLocation.GetFileAsync("mymusic.mp3"); var audio = await BackgroundAudioTrack.CreateFromFileAsync(file); mediaComposition.BackgroundAudioTracks.Add(audio); © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

28 Playback and rendering to a file
11/17/2018 Playback and rendering to a file // Play the composed result including all clips and the audio track in a Xaml MediaElement var w = (int) MediaElement.ActualWidth; var h = (int) MediaElement.ActualHeight; MediaElement.SetMediaStreamSource(mediaComposition.GeneratePreviewMediaStreamSource(w, h))); // Create output file var vidLib = KnownFolders.VideosLibrary; var resultFile = await vidLib.CreateFileAsync("myComposition.mp4",  CreationCollisionOption.ReplaceExisting); // Encode new composition as MP4 to the file var mediaEncodingProfile = MediaEncodingProfile.CreateMp4(VideoEncodingQuality.Vga); await mediaComposition.RenderToFileAsync(resultFile, MediaTrimmingPreference.Fast, mediaEncodingProfile); © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

29 11/17/2018 Demo VideoEditing © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

30 Background Audio

31 Background Audio Playback
11/17/2018 Background Audio Playback Windows.Media.BackgroundPlayback New MediaPlayer class replaces the BackgroundAudioPlayer Only available for WinRT-based phone apps, not for Silverlight 8.1 MediaPlayer Uses two-process model with foreground UI and background playback Continues playback via background process when app navigates away Can also be used in foreground for playback even without MediaElement Different than Windows 8.1 model: MediaElement.AudioCategory="BackgroundCapableMedia" © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

32 Background Audio Process
11/17/2018 Background Audio Process Defined in a WinRT component Entry point declared in AppxManifest Custom BackgroundAudioTask class implements IBackgroundTask and its Run method Access to global instance through BackgroundMediaPlayer.Current Inter-process communication via BackgroundMediaPlayer .SendMessageToBackground(…) .SendMessageToForeground(…) © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

33 Universal Volume Control
11/17/2018 Universal Volume Control SystemMediaTransportControls The SystemMediaTransportControls (SMTC) API provides access to the device’s Universal Volume Control (UVC) SMTC allows to define which buttons are enabled in the UVC SMTC DisplayUpdater provides a way to set the UVC text like title, etc. ButtonPressed event of the SMTC needs to be synced to the MediaPlayer and vice versa Event is triggered in background process as well © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

34 Implementing Background Audio

35 MediaPlayer Play, Pause and Stop
11/17/2018 MediaPlayer Play, Pause and Stop // Attach event handler to background player to update UI BackgroundMediaPlayer.Current.CurrentStateChanged += MediaPlayerStateChanged; // Uri could also be ms-appx:/// for package-local tracks BackgroundMediaPlayer.Current.SetUriSource(new Uri(" // Starts play since MediaPlayer.AutoPlay=true by default // Or trigger manually play when AutoPlay=false BackgroundMediaPlayer.Current.Play(); // Pause. BackgroundMediaPlayer.Current.Pause(); // Stop. There's no MediaPlayer.Stop() method BackgroundMediaPlayer.Current.Pause(); BackgroundMediaPlayer.Current.Position = TimeSpan.FromSeconds(0); © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

36 Updating UI in MediaPlayer.CurrentStateChanged
11/17/2018 Updating UI in MediaPlayer.CurrentStateChanged private async void MediaPlayerStateChanged(MediaPlayer sender, object args) {     // This event is called from a background thread, so dispatch to UI      await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>     {         switch (BackgroundMediaPlayer.Current.CurrentState)         {             case MediaPlayerState.Playing:                 AppBarBtnPause.IsEnabled = true;                 // Pass params on to background process, so it can update the UVC text there                 BackgroundMediaPlayer.SendMessageToBackground(new ValueSet                 { {"Title", "My Super MP3"}, {"Artist", "Foo Bar"} });                 break;             case MediaPlayerState.Paused:                 AppBarBtnPause.IsEnabled = false;                 break;         }     }); } © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

37 BackgroundAudioTask wiring up SMTC and UVC
11/17/2018 BackgroundAudioTask wiring up SMTC and UVC public void Run(IBackgroundTaskInstance taskInstance) {     // Initialize SMTC object to talk with UVC     // This is intended to run after app is paused, // therefore all the logic must be written to run in background process     systemmediatransportcontrol = SystemMediaTransportControls.GetForCurrentView();     systemmediatransportcontrol.ButtonPressed += SystemControlsButtonPressed;     systemmediatransportcontrol.IsEnabled = true;     systemmediatransportcontrol.IsPauseEnabled = true;     systemmediatransportcontrol.IsPlayEnabled = true;     // Add handlers to update SMTC when MediaPlayer is used in foreground     BackgroundMediaPlayer.Current.CurrentStateChanged += BackgroundMediaPlayerCurrentStateChanged;     BackgroundMediaPlayer.MessageReceivedFromForeground += BackgroundMediaPlayerOnMessageReceived; } © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

38 BackgroundAudioTask updating UVC text
11/17/2018 BackgroundAudioTask updating UVC text private void BackgroundMediaPlayerOnMessageReceived(object sender, MediaPlayerDataReceivedEventArgs e) {     // Update the UVC text     systemmediatransportcontrol.DisplayUpdater.Type = MediaPlaybackType.Music;     systemmediatransportcontrol.DisplayUpdater.MusicProperties.Title = e.Data["Title"].ToString();     systemmediatransportcontrol.DisplayUpdater.MusicProperties.Artist = e.Data["Artist"].ToString();     systemmediatransportcontrol.DisplayUpdater.Update(); } © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

39 Demo BackgroundAudio 11/17/2018
© 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

40 11/17/2018 Summary © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

41 Adding it all up – Media I/O
11/17/2018 Adding it all up – Media I/O Windows Phone 8 Windows Phone 8.1 Silverlight Windows Phone 8.1 WinRT Windows 8.1 Getting photos PhotoChooserTask XNA MediaLibrary FileOpenPicker KnownFolders CameraCaptureUI FileOpenPicker Storing photos XNA MediaLibrary FileSavePicker Getting videos No CameraCaptureUI FileOpenPicker Storing videos © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

42 Adding it all up – Capturing
11/17/2018 Adding it all up – Capturing Windows Phone 8 Windows Phone 8.1 Silverlight Windows Phone 8.1 WinRT Windows 8.1 Windows.Phone. Media.Capture Yes No Windows. Media.Capture VariablePhoto-SequenceCapture ScreenCapture © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

43 Adding it all up – Media Editing
11/17/2018 Adding it all up – Media Editing Windows Phone 8 Windows Phone 8.1 Silverlight Windows Phone 8.1 WinRT Windows 8.1 Windows.Media. Editing No Yes Windows.Media. Transcoding © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

44 Adding it all up – Background Audio
11/17/2018 Adding it all up – Background Audio Windows Phone 8 Windows Phone 8.1 Silverlight Windows Phone 8.1 WinRT Windows 8.1 Windows.Media. BackgroundPlayback No Yes Microsoft.Phone. BackgroundAudio MediaElement  AudioCategory= "BackgroundCapableMedia" © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

45


Download ppt "Camera, Media and Audio in Windows Phone 8.1"

Similar presentations


Ads by Google