Jump to content

sound loc/playing it

- - - - -

  • Please log in to reply
4 replies to this topic

#1
Endiss

Endiss

    Newbie

  • Members
  • Pip
  • 3 posts
Hi,
I've got problem with playing sounds from windows.form program that contains folder sounds with 1 sound.wav

spWave.SoundLocation = "sounds/blue_buff.wav";
spWave.Play();

This patch saying is wrong and program crash ... any ideas?

#2
fayyazlodhi

fayyazlodhi

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 403 posts
My first doubt is on the location variable. To be sure, Hard code the full absolute path starting from drive letter like "c:...".

Your current working directory depends upon what type of project you have created. Using Visual studio might be different from others.

Also there is very little reference to the rest of your code i.e. if the class type of spWave is correct etc.
Today is the first day of the rest of my life

#3
Tonchi

Tonchi

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 471 posts
  • Location:Varaždin
  • Programming Language:C, C++, C#
and what is the class for mp3 files???

#4
Endiss

Endiss

    Newbie

  • Members
  • Pip
  • 3 posts
here is simple mp3 player u can look on it and use it

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

using System.Runtime.InteropServices;


namespace mp3_player

{

    public partial class Form1 : Form

    {

        [DllImport("winmm.dll")]

        private static extern long mciSendString(string strCommand, StringBuilder strReturn, int iReturnLength, IntPtr hwndCallback);

        public Form1()

        {

            InitializeComponent();

        }


        private void wybierz_Click(object sender, EventArgs e)

        {

            if (fileopen.ShowDialog() == DialogResult.OK)

            {

                nazwa_piosenki.Text = fileopen.FileName; //name of song aka location of it


                Play.Enabled = true;

            }

        }


        private void Play_Click(object sender, EventArgs e)

        {

            mciSendString("open \"" + nazwa_piosenki.Text + "\" type mpegvideo alias MediaFile", null, 0, IntPtr.Zero);

            mciSendString("play MediaFile", null, 0, IntPtr.Zero);


            Play.Enabled = false;

            stop.Enabled = true;

        }


        private void stop_Click(object sender, EventArgs e)

        {

            mciSendString("close MediaFile", null, 0, IntPtr.Zero);


            stop.Enabled = false;

            Play.Enabled = true;

        }

    }

}


#5
Tonchi

Tonchi

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 471 posts
  • Location:Varaždin
  • Programming Language:C, C++, C#
is this a syntax for using some dll???


[DllImport("winmm.dll")]


and what about that dll??? does it contain some classes and methods like SDK's???
and does that dll must be inside my project in specific file or not???




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users