1

Alguien me podría orientar respecto a un problema con un componente COM en c#, esto para adjuntarlo a un Form, con el framework .NET, el COM en cuestión es El Windows Media Player(WMP), he tratado de realizar un reproductor de video, la función de agregar a lista, abrir archivos todo bien, pero este al intentar reproducirlos no lo hace y mas bien me cierra el programa, no he programado ninguna función para que cuando se reproduzca algo se cierre, en depuración me sale un error que corresponde a esto: termino con código -1073741819 (0xc0000005) 'Access violation'.

He intentado probar el programa en diferentes computadoras, pero es el mismo problema, este no reproduce, simplemente se cierra.

Cualquier ayuda será, bienvenida.

Adjunto código:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        string[] paths, files;

        private void track_list_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                player.URL = paths[track_list.SelectedIndex];

                player.Ctlcontrols.play();

                lbl_msg.Text = "Playing...";

                timer1.Start();

                trackBar1.Value = 15;

                lbl_volume.Text = trackBar1.Value.ToString() + "%";

            }
            catch (AccessViolationException av)
            {
                MessageBox.Show(String.Format("An error occured\nTechnical error: {0}"), av.Message);
            }




        }


        private void btn_play_Click(object sender, EventArgs e)
        {
            player.Ctlcontrols.play();

            lbl_msg.Text = "Playing...";
        }

        private void btn_pause_Click(object sender, EventArgs e)
        {
            player.Ctlcontrols.pause();

            lbl_msg.Text = "Pause";
        }

        private void btn_stop_Click(object sender, EventArgs e)
        {
            player.Ctlcontrols.stop();

            lbl_msg.Text = "Stop";
        }

        private void btn_next_Click(object sender, EventArgs e)
        {
            if (track_list.SelectedIndex < track_list.Items.Count - 1)

            {

                track_list.SelectedIndex = track_list.SelectedIndex + 1;

            }
        }

        private void btn_prev_Click(object sender, EventArgs e)
        {
            if (track_list.SelectedIndex > 0)

            {

                track_list.SelectedIndex = track_list.SelectedIndex - 1;

            }
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            if (player.playState == WMPLib.WMPPlayState.wmppsPlaying)

            {

                progressBar1.Maximum = (int)player.Ctlcontrols.currentItem.duration;

                progressBar1.Value = (int)player.Ctlcontrols.currentPosition;



            }

            lbl_track_start.Text = player.Ctlcontrols.currentPositionString;

            lbl_track_end.Text = player.Ctlcontrols.currentItem.durationString.ToString();
        }

        private void trackBar1_Scroll(object sender, EventArgs e)
        {
            player.settings.volume = trackBar1.Value;

            lbl_volume.Text = trackBar1.Value.ToString() + "%";
        }

        private void btn_open_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Multiselect = true;

            if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)

            {

                files = ofd.SafeFileNames;

                paths = ofd.FileNames;

                for (int x = 0; x < files.Length; x++)

                {

                    track_list.Items.Add(files[x]);

                }

            }
        }
    }
}

2
  • 1
    podra ser una incompatibilidad entre algo de 32 bits y algo de 64?
    – gbianchi
    el 9 ago. 2021 a las 4:05
  • Es curioso, por qué, la primera prueba dió, luego reinicie la PC y el programa dejo de funcionar...
    – Asxoyr
    el 9 ago. 2021 a las 12:24

1 respuesta 1

0

Puede que el antivirus que tengas instalado a detectado el System.Threading.Tasks

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
' Comenta y Prueba de Nuevo using System.Threading.Tasks;
using System.Windows.Forms;
1
  • A mi me paso algo parecido y tuve que comentar algo de código huérfano que tenia relación con el System.Threading el 21 nov. 2021 a las 14:19

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge you have read our privacy policy.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.