why I can’t pause the sound/music?

so uhh I was trying to make a media player for my first project in C#.NET (my biggest mistake)
after like straight 7 hours of stealing peoples code from other answers in other questions I just had a problem that i can’t find out how to fix it… so annoying
and I guess I know the problem but I don’t know how to fix it…

the problem is when i press the btn that starts the sound/music … it works fine but it doesn’t stop the goddam sound and starts a new music instead… any help plkz? PLKZ? PPPLLLKKKZZZ?
I’m working on this problem for straight 11:30 hours plkz help me ;^;

(I hope I didn’t made any mistake in learning the C# when I’m only 14 years old and jumping from JS and PHP to C# anyway it doesn’t matter I’m in this now ????)

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;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
using System.Media;
using NAudio.Wave;
using TagLib;
using System.IO;
using WindowsFormsApp1.Properties;


namespace WindowsFormsApp1
{
    public partial class Form1 : Form
    {
        int playing = 0;
        public Form1()
        {
            InitializeComponent();
            this.AllowDrop = true;
            this.DragEnter += new DragEventHandler(Form1_DragEnter);
            this.DragDrop += new DragEventHandler(Form1_DragDrop);
        } 

        public static class GlobalFilePath
        {
            public static string FilePath { get; set; }

        }

        

        public void ReadMp3Metadata(string mp3FilePath)
        {
            // Open the MP3 file
            var mp3File = TagLib.File.Create(mp3FilePath);

            // Read the title (name) of the song
            string title = Path.GetFileNameWithoutExtension(mp3FilePath);
            label1.Text = title;

            // Check if there are any pictures
            if (mp3File.Tag.Pictures.Length > 0)
            {
                // Get the first embedded picture
                IPicture pic = mp3File.Tag.Pictures[0];

                // Extract image data (byte array)
                byte[] imageData = pic.Data.Data;
                // You can convert it to an Image object if needed
                Image albumArt = Image.FromStream(new MemoryStream(imageData));
                pictureBox2.BackgroundImage = albumArt;
            }


            // Don't forget to dispose the file to free resources
            mp3File.Dispose();
        }

        void Form1_DragEnter(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
                e.Effect = DragDropEffects.Copy;
        }

        void Form1_DragDrop(object sender, DragEventArgs e)
        {
            string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
            if (files != null && files.Length > 0)
            {
                // Store the first file path globally
                GlobalFilePath.FilePath = files[0];
                ReadMp3Metadata(GlobalFilePath.FilePath);
            }
        }


        private void button2_Click(object sender, EventArgs e)
        {
        string path = GlobalFilePath.FilePath;
        if (path != null)
            {
                var mp3Reader = (Mp3FileReader)null;
                var waveOut = (WaveOut)null;
                ReadMp3Metadata(path);
                if (playing == 0)           
                {
                    waveOut.Play();
                    playing = 2;
                    Console.WriteLine(playing);
                } 
                else if(playing == 1)
                {
                    waveOut.Stop(); 
                    playing = 1;
                    Console.WriteLine(playing);
                }
            }
        }

I tried many things many methods many other ways but non of them work
like making lot of class and functions
but still no no work

New contributor

hackergod1212 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật