none
[UWP]Cant see snap shot pictures in Pictures folder RRS feed

  • Question

  • I am trying to take snapshot of live running video. But when select button for capture, i dont see any picture in Pictures folder. Here is my code kidly help:

    Xaml:

    
    <Page
        x:Class="tvfinal.MainPage"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="using:tvfinal"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d">
    
        <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
            <StackPanel>
    
    
                <MediaElement x:Name="mediaElement" HorizontalAlignment="Left" Height="486" Margin="10,10,0,0" VerticalAlignment="Top" Width="340"/>
    
    
                <StackPanel x:Name="RenderedGrid" Orientation="Horizontal">
    
    
                    <Button Content="Play" Margin="5" Height="45" Width="100"         Click="Button_Click"></Button>
                    <Button Content="Pause" Margin="5" Height="45" Width="100"         Click="Button_Click_1"></Button>
                    <Button Content="Capture" Margin="5" Height="45" Width="100"         Click="Button_Click_2"></Button>
    
                </StackPanel>
    
    
            </StackPanel>
        </Grid>
    </Page>

    XAML.CS

    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using System.Runtime.InteropServices.WindowsRuntime;
    using Windows.Foundation;
    using Windows.Foundation.Collections;
    using Windows.Storage.Pickers;
    using Windows.UI.Xaml;
    using Windows.UI.Xaml.Controls;
    using Windows.UI.Xaml.Controls.Primitives;
    using Windows.UI.Xaml.Data;
    using Windows.UI.Xaml.Input;
    using Windows.UI.Xaml.Media;
    
    using Windows.UI.Xaml.Media.Imaging;
    using Windows.UI.Xaml.Navigation;
    // The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
    
    namespace tvfinal
    {
        /// <summary>
        /// An empty page that can be used on its own or navigated to within a Frame.
        /// </summary>
        public sealed partial class MainPage : Page
        {
            public MainPage()
            {
                this.InitializeComponent();
            }
    
            private void Button_Click(object sender, RoutedEventArgs e)
            {
                mediaElement.Source = new Uri("http://esioslive6-i.akamaihd.net/hls/live/202874/AL_P_ESP1_INTER_ENG/playlist_1000.m3u8");
    
    
                mediaElement.Play();
            }
    
            private void Button_Click_1(object sender, RoutedEventArgs e)
            {
                mediaElement.Pause();
            }
    
            private async void Button_Click_2(object sender, RoutedEventArgs e)
            {
                RenderTargetBitmap renderTargetBitmap = new RenderTargetBitmap();
                await renderTargetBitmap.RenderAsync(RenderedGrid);
                var pixelBuffer = await renderTargetBitmap.GetPixelsAsync();
    
                var savePicker = new FileSavePicker();
                savePicker.DefaultFileExtension = ".png";
                savePicker.FileTypeChoices.Add(".png", new List<string> { ".png" });
                savePicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
                savePicker.SuggestedFileName = "snapshot.png";
            }
        }
    }
    I really could not able to find out where is my picture going??? I also debugged but failed to understand. Kindly help.......


    • Edited by Barry Wang Thursday, August 4, 2016 9:50 AM title tag
    Monday, August 1, 2016 10:49 AM

Answers

  • Somehow I remember that RenderTargetBitmap cannot capture the medie element's screenshot, probably you can find such information from the MSDN documentation.

    If the mechanism does not allow to take screenshot, definitely you cannot find any image. 


    • Proposed as answer by Jayden Gu Wednesday, August 10, 2016 6:32 AM
    • Marked as answer by Barry Wang Friday, August 12, 2016 12:39 AM
    Friday, August 5, 2016 3:18 AM
  • Hello,

    The article use the RenderTargetBitmap to take snapshot for the normal UIElement, but the MediaElement is different from them. Video content in a MediaElement or CaptureElement can't be captured using RenderTargetBitmap. Please check it in the remark with the following link: https://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.media.imaging.rendertargetbitmap.aspx.

    Best Regards,

    Jayden Gu

    • Proposed as answer by Jayden Gu Wednesday, August 10, 2016 6:32 AM
    • Marked as answer by Barry Wang Friday, August 12, 2016 12:39 AM
    Friday, August 5, 2016 11:50 AM

All replies