IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

 .NET Discussion :

Ouvrir une vidéo avec MediaElement [C#]


Sujet :

.NET

  1. #1
    Membre à l'essai
    Homme Profil pro
    Étudiant
    Inscrit en
    Juillet 2013
    Messages
    15
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Juillet 2013
    Messages : 15
    Points : 10
    Points
    10
    Par défaut Ouvrir une vidéo avec MediaElement
    Bonjour,

    j'essaye depuis peu d'ouvrir un vidéo via un "MediaElement", sauf que j'obtiens une exception que je ne comprend pas.

    Voici le code :

    Code xaml : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    <Window x:Class="WpfApplication1.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Title="MainWindow" Height="350" Width="525">
        <Grid>
            <MediaElement Name="medial" Source="C:\Users\Kira\Desktop\l.mp3"/>
        </Grid>
    </Window>

    et voici l'exception que j'obtiens lorsque je mets le liens (source) de ma vidéo :

    System.InvalidOperationException
    File d'attente vide.
    à System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
    à System.Collections.Generic.Queue`1.Dequeue()
    à Microsoft.Expression.WpfPlatform.InstanceBuilders.MediaElementThumnailGrabber.MoveToNextWorkItem(BitmapSource image, String errorMessage)
    à Microsoft.Expression.WpfPlatform.InstanceBuilders.MediaElementThumnailGrabber.OnMediaFailed(Object sender, ExceptionEventArgs e)
    à System.Windows.Media.UniqueEventHelper`1.InvokeEvents(Object sender, TEventArgs args)
    à System.Windows.Media.MediaEventsHelper.OnMediaFailed(Object o)
    à System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
    à MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
    à System.Windows.Threading.DispatcherOperation.InvokeImpl()
    à System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
    à System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
    à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
    à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
    à System.Windows.Threading.DispatcherOperation.Invoke()
    à System.Windows.Threading.Dispatcher.ProcessQueue()
    à System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
    à MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
    à MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
    à System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
    à MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
    à System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
    à MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
    à MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
    à System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
    à System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
    à System.Windows.Threading.Dispatcher.Run()
    à System.Windows.Application.RunDispatcher(Object ignore)
    à System.Windows.Application.RunInternal(Window window)
    à System.Windows.Application.Run(Window window)
    à System.Windows.Application.Run()
    à Microsoft.Expression.DesignHost.Isolation.DesignerProcess.RunApplication()
    à Microsoft.Expression.DesignHost.Isolation.DesignerProcess.<>c__DisplayClass2.<Main>b__0()
    à System.Threading.ThreadHelper.ThreadStart_Context(Object state)
    à System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
    à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
    à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
    à System.Threading.ThreadHelper.ThreadStart()

    Bien que j'ai cette exception le programme se lance mais ne m'ouvre qu'une fenêtre sans rien dessus.

  2. #2
    Membre éprouvé Avatar de Momoth
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Mars 2013
    Messages
    318
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 32
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mars 2013
    Messages : 318
    Points : 1 236
    Points
    1 236
    Par défaut
    Bonjour,

    Essaye de passer par une Uri en C# plutôt que de mettre une source comme ça.

    Ça devrait te donner ce genre de code :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    medial.Source = new Uri(@"C:\Users\Kira\Desktop\l.mp3");
    Si cela ne corrige pas ton problème, essaye sinon de lancer l'application en pas à pas détaillé pour voir quand est ce qu'elle craque.
    La Triforce du développement : Fainéantise, Curiosité et Imagination.

  3. #3
    Membre à l'essai
    Homme Profil pro
    Étudiant
    Inscrit en
    Juillet 2013
    Messages
    15
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Juillet 2013
    Messages : 15
    Points : 10
    Points
    10
    Par défaut
    J'ai déjà essayer pour le lien Uri, cela ne fonctionnait pas non plus.
    De plus le pas à pas détaillé ne fonctionne pas non plus, cela m'ouvre tout simplement une fenêtre comme tout à l'heure mais la musique ne se lance pas.

  4. #4
    Membre à l'essai
    Homme Profil pro
    Étudiant
    Inscrit en
    Juillet 2013
    Messages
    15
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Juillet 2013
    Messages : 15
    Points : 10
    Points
    10
    Par défaut
    Alors après avoir utiliser ta méthode Momoth (Uri) j'ai essayer de faire :
    ce qui m'a donner une exception :

    Source indisponible, il manque des informations source dans les informations de débogage de ce module.

  5. #5
    Membre éprouvé Avatar de Momoth
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Mars 2013
    Messages
    318
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 32
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mars 2013
    Messages : 318
    Points : 1 236
    Points
    1 236
    Par défaut
    J'ai réussis à reproduire ton bug. Je pense que le soucis vient du LoadedBehavior, personnellement ça me lançait le lecteur mais sans le son.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    medial.Source = new Uri(@"C:\Users\Kira\Desktop\l.mp3");
    medial.LoadedBehavior = MediaState.Play;
    Ceci à marché pour moi.
    La Triforce du développement : Fainéantise, Curiosité et Imagination.

  6. #6
    Membre à l'essai
    Homme Profil pro
    Étudiant
    Inscrit en
    Juillet 2013
    Messages
    15
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Juillet 2013
    Messages : 15
    Points : 10
    Points
    10
    Par défaut
    Toujours pareil mais c'est vrai que l'exception est partis.
    Je pense que mon problème viens du fait est que je suis sur un Windows via bootcamp Mac os, cela peut il causer des problèmes?

  7. #7
    Membre éprouvé Avatar de Momoth
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Mars 2013
    Messages
    318
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 32
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mars 2013
    Messages : 318
    Points : 1 236
    Points
    1 236
    Par défaut
    Je connais ce système que de nom, mais il me semble que tu dois installer les drivers de ton matériel pour l'environnement Windows. Peut être le problème vient des drivers de ta carte son non installé pour windows ?
    La Triforce du développement : Fainéantise, Curiosité et Imagination.

  8. #8
    Membre à l'essai
    Homme Profil pro
    Étudiant
    Inscrit en
    Juillet 2013
    Messages
    15
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Juillet 2013
    Messages : 15
    Points : 10
    Points
    10
    Par défaut
    Non je ne pense pas, vu qu'a l’installation de Windows j'ai bien installer tous les drivers.

    Alors voici tout le code au cas ou si tu vois une erreur :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;
     
    namespace WpfApplication1
    {
        /// <summary>
        /// Logique d'interaction pour MainWindow.xaml
        /// </summary>
        public partial class MainWindow : Window
        {
            public MainWindow()
            {
                InitializeComponent();
     
                medial.Source = new Uri(@"C:\Users\Kira\Desktop\lol.mp4");
                medial.LoadedBehavior = MediaState.Play;
            }
        }
    }
    Code xaml : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    <Window x:Class="WpfApplication1.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Title="MainWindow" Height="350" Width="525">
        <Grid>
            <MediaElement Name="medial"/>
        </Grid>
    </Window>

    Donc j'ai également essayer avec une vidéo mais toujours rien. Toujours la fenêtre qui s'ouvre mais rien qui se lance.

  9. #9
    Membre éprouvé Avatar de Momoth
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Mars 2013
    Messages
    318
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 32
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mars 2013
    Messages : 318
    Points : 1 236
    Points
    1 236
    Par défaut
    Ajoute l’événement MediaFailed à ton xaml et dans la méthode créée, ajoute :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    private void medial_MediaFailed(object sender, ExceptionRoutedEventArgs e)
    {
         MessageBox.Show(e.ErrorException.ToString());
    }
    La Triforce du développement : Fainéantise, Curiosité et Imagination.

  10. #10
    Membre à l'essai
    Homme Profil pro
    Étudiant
    Inscrit en
    Juillet 2013
    Messages
    15
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Juillet 2013
    Messages : 15
    Points : 10
    Points
    10
    Par défaut
    Super cool, c'est bon sa marche =) en faite je n'avais pas windows media player sur mon ordinateur et du coup sa ne lancer rien du tout. (c'est l'exceptions du MediaFailed qui m'a aider).

    Merci beaucoup en tout cas.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 13
    Dernier message: 08/11/2006, 23h34
  2. Ouvrir une vidéo en C++
    Par SteveOS dans le forum Bibliothèques
    Réponses: 8
    Dernier message: 04/01/2006, 15h36
  3. Ouvrir une image avec paint depuis un formulaire
    Par gui38 dans le forum Access
    Réponses: 3
    Dernier message: 14/11/2005, 16h40
  4. ouvrir une popup avec php
    Par Defrancesco dans le forum Général JavaScript
    Réponses: 1
    Dernier message: 15/10/2005, 10h34
  5. [Eclipse 3.1] ouvrir une fenetre avec un bouton
    Par Nanoulov dans le forum SWT/JFace
    Réponses: 4
    Dernier message: 01/08/2005, 13h33

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo