Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
3.50/5 (2 votes)
See more:
So i have a windows media player component in my visual studio, and I want it to play a video once the form loads. So i put the media player on my form, and I have a video in my resources to set as the media player url. But when i try it, it says cannot convert byte[] to string .-.
(btw MediaPlayer1 is my windows media player on my form)

If you didnt get it, my problem is i want to link the mediaplayer url to a file in my resources but it says cannot convert byte[] to string

Heres my code

Main class:
C#
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 doit2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            Song.play();
            
            InitializeComponent();
        }
    }
}


Song class:
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Media;
using System.Reflection;
using System.IO;
using System.Diagnostics;

namespace doit2
{
    class Song
    {

        public static void play()
        {
            using (Form1 form = new Form1()) form.MediaPlayer1.URL = Properties.Resources.doitVideo;// the doitvideo is my file in resources, its an mp4
            using (Form1 form = new Form1()) form.MediaPlayer1.Ctlcontrols.play();
        }

    }
}
Posted
Updated 23-Sep-15 9:36am
v3

1 solution

Mediaplayer indirectly uses windows media player.
As a result, video will play if the media player installation (on this system) supports mp4.

If not, then a codec pack needs to be installed to play this video.
 
Share this answer
 
Comments
Member 10812829 22-Sep-15 22:05pm    
So i just need to convert it to a .wmv?
Abhinav S 22-Sep-15 22:12pm    
Or you could download the codec / driver that runs mp4 on media player.
Member 10812829 22-Sep-15 22:06pm    
And also my problem is that I need to link the mediaplayer url to a file in my resources, but thx for that anyways
CPallini 23-Sep-15 15:42pm    
5.
Abhinav S 23-Sep-15 22:21pm    
Thanks.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900