Mon diaporama marche pas

Fermé
Utilisateur anonyme - Modifié le 21 oct. 2022 à 10:26
Grandasse_ Messages postés 924 Date d'inscription jeudi 28 janvier 2010 Statut Membre Dernière intervention 27 avril 2023 - 21 oct. 2022 à 11:17

***** Bonjour.


ce code photo ne marche pas

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Devices.Enumeration;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.Media.Core;
using Windows.Media.Devices;
using Windows.Media.Playback;
using Windows.Storage;
using Windows.Storage.FileProperties;
using Windows.UI.Popups;
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.Navigation;

// Pour plus d'informations sur le modèle d'élément Page vierge, consultez la page https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409

namespace TP4_NET
{
    /// <summary>
    /// Une page vide peut être utilisée seule ou constituer une page de destination au sein d'un frame.
    /// </summary>
    public sealed partial class MainPage : Page
    {
        bool click = false;
        public MainPage()
        {
            this.InitializeComponent();
        }

        string gfilename;
        string gfiledate;
        string gfilesize;
        private async void Selection_Fichier(object sender, RoutedEventArgs e)
        {
            var pck = new Windows.Storage.Pickers.FileOpenPicker();
            pck.ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail;
            pck.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.VideosLibrary;
            pck.FileTypeFilter.Add(".mp4");
            pck.FileTypeFilter.Add(".avi");
            pck.FileTypeFilter.Add(".wmw");
            // sans le await sa va provoquer des erreur
            var fichier = await pck.PickSingleFileAsync();

            if(fichier != null)
            {
                gfilename = fichier.Name;
                gfiledate = fichier.DateCreated.ToString();
                Windows.Storage.FileProperties.BasicProperties bp = await fichier.GetBasicPropertiesAsync();
                gfilesize = bp.Size.ToString();
                
                mediaplayer.Source = MediaSource.CreateFromStorageFile(fichier);
                mediaplayer.MediaPlayer.Play();
            }


        }

        private  void Pause(object sender, RoutedEventArgs e)
        {
            try
            {
                mediaplayer.MediaPlayer.Pause();
            }
            catch { }
        }
        private void Play(object sender, RoutedEventArgs e)
        {
            try
            {
                mediaplayer.MediaPlayer.Play();
            }
            catch { }
        }

        private async void Lopp(object sender, RoutedEventArgs e)
        {
            
            if (mediaplayer.Source != null)
            {

                mediaplayer.MediaPlayer.IsLoopingEnabled = true;
            }
            if (click == false)
            {
                Loop.Icon = new SymbolIcon(Symbol.RepeatAll);
                click= true;
            }

            else if (click == true)
            {
                Loop.Icon = new SymbolIcon(Symbol.Next);
                click = false;
            }
        }

        private async void info_video(object sender, RoutedEventArgs e)
        {
            

            MessageDialog message = new MessageDialog("information de la video", "Info");
            message.Content = "taille :"+ gfilesize+Environment.NewLine;
            message.Content += "Nom : " + gfilename+Environment.NewLine;
            message.Content += "Date : " + gfiledate + Environment.NewLine;
            // message.Content += "durée : " + mediaplayer.MediaPlayer + Environment.NewLine;


        }

        private async void RateM(object sender, RoutedEventArgs e)
        {
            if (mediaplayer.Source == null)
            {
                MessageDialog msgbox = new MessageDialog("Pas de fichier sélectionné !",
                "Attention");
                await msgbox.ShowAsync();
                return;
            }
            mediaplayer.MediaPlayer.PlaybackRate /= 2;
        }
        private async void Volume(object sender, RoutedEventArgs e)
        {
            if (mediaplayer.Source == null)
            {
                MessageDialog msgbox = new MessageDialog("Pas de fichier sélectionné !",
                "Attention");
                await msgbox.ShowAsync();
                return;
            }
            if (mediaplayer.MediaPlayer.IsMuted)
            {
                mediaplayer.MediaPlayer.IsMuted = false;
                bt_Volume.Icon = new SymbolIcon(Symbol.Mute);
            }
            else
            {
                mediaplayer.MediaPlayer.IsMuted = true;
                bt_Volume.Icon = new SymbolIcon(Symbol.Volume);
            }
        }
        private async void Device(object sender, RoutedEventArgs e)
        {
            string audioSelector = MediaDevice.GetAudioRenderSelector();
            var outputDevices = await DeviceInformation.FindAllAsync(audioSelector);
            string strDevice = "";
            foreach (var device in outputDevices)
            {
                strDevice = device.Name;
                strDevice += Environment.NewLine;
            }
            MessageDialog msgbox = new MessageDialog(strDevice, "Sorties audio");
            await msgbox.ShowAsync();
        }
        private async void Jump(object sender, RoutedEventArgs e)
        {
            var session = mediaplayer.MediaPlayer.PlaybackSession;
            Button bt = (Button)sender;
            if (bt.Name == "bt_R")
            {
                session.Position = session.Position + TimeSpan.FromSeconds(30);
            }
            else
            {
                session.Position = new TimeSpan(0);
            }
        }


    }
}

Voir cette page

1 réponse

Grandasse_ Messages postés 924 Date d'inscription jeudi 28 janvier 2010 Statut Membre Dernière intervention 27 avril 2023 592
21 oct. 2022 à 11:17

Bonjour,

Merci de nous indiquer là où tu bloques, et ce que tu as essayé pour t'en sortir.

Merci aussi de ne pas nous donner ton TP à réaliser à ta place...


0