コード例 #1
0
ファイル: cd_win.cs プロジェクト: epiczombies/SharpQuake-v2.0
    public void Resume()
    {
        if (!_IsEnabled)
        {
            return;
        }

        if (!_IsValidDisc)
        {
            return;
        }

        if (!_WasPlaying)
        {
            return;
        }

        Mci.MCI_PLAY_PARMS pp;
        pp.dwFrom     = Mci.MCI_MAKE_TMSF(_PlayTrack, 0, 0, 0);
        pp.dwTo       = Mci.MCI_MAKE_TMSF(_PlayTrack + 1, 0, 0, 0);
        pp.dwCallback = _Form.Handle;// (DWORD)mainwindow;
        int ret = Mci.Play(_DeviceID, Mci.MCI_PLAY, Mci.MCI_TO | Mci.MCI_NOTIFY, ref pp);

        if (ret != 0)
        {
            game_engine.Con_DPrintf("CDAudio: MCI_PLAY failed ({0})\n", ret);
        }

        _IsPlaying = (ret == 0);
    }
コード例 #2
0
ファイル: StartForm.cs プロジェクト: muhliz25/cs-codebook
 private void playButton_Click(object sender, System.EventArgs e)
 {
     try
     {
         mci.Play(this.repeatCheckBox.Checked);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
コード例 #3
0
        static void Main(string[] args)
        {
            string fileName = Path.Combine(Application.StartupPath, "Club Generation - Patience.mp3");

            try
            {
                // Leider funktioniert MCI (auf jeden Fall auf meinem XP-System)
                // nicht in einer Konsolenanwendung
                Mci mci = new Mci();
                mci.Open(fileName);
                mci.Play(true);
                Console.WriteLine("Abspielen beenden mit Return");
                mci.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }



            Console.WriteLine("Beenden mit Return");
            Console.ReadLine();
        }
コード例 #4
0
ファイル: cd_win.cs プロジェクト: epiczombies/SharpQuake-v2.0
    public void Play(byte track, bool looping)
    {
        if (!_IsEnabled)
        {
            return;
        }

        if (!_IsValidDisc)
        {
            CDAudio_GetAudioDiskInfo();
            if (!_IsValidDisc)
            {
                return;
            }
        }

        track = _Remap[track];

        if (track < 1 || track > _MaxTrack)
        {
            game_engine.Con_DPrintf("CDAudio: Bad track number {0}.\n", track);
            return;
        }

        // don't try to play a non-audio track
        Mci.MCI_STATUS_PARMS sp = default(Mci.MCI_STATUS_PARMS);
        sp.dwItem  = Mci.MCI_CDA_STATUS_TYPE_TRACK;
        sp.dwTrack = track;
        int ret = Mci.Status(_DeviceID, Mci.MCI_STATUS, Mci.MCI_STATUS_ITEM | Mci.MCI_TRACK | Mci.MCI_WAIT, ref sp);

        if (ret != 0)
        {
            game_engine.Con_DPrintf("MCI_STATUS failed ({0})\n", ret);
            return;
        }
        if (sp.dwReturn != Mci.MCI_CDA_TRACK_AUDIO)
        {
            game_engine.Con_Printf("CDAudio: track {0} is not audio\n", track);
            return;
        }

        // get the length of the track to be played
        sp.dwItem  = Mci.MCI_STATUS_LENGTH;
        sp.dwTrack = track;
        ret        = Mci.Status(_DeviceID, Mci.MCI_STATUS, Mci.MCI_STATUS_ITEM | Mci.MCI_TRACK | Mci.MCI_WAIT, ref sp);
        if (ret != 0)
        {
            game_engine.Con_DPrintf("MCI_STATUS failed ({0})\n", ret);
            return;
        }

        if (_IsPlaying)
        {
            if (_PlayTrack == track)
            {
                return;
            }
            Stop();
        }

        Mci.MCI_PLAY_PARMS pp;
        pp.dwFrom     = Mci.MCI_MAKE_TMSF(track, 0, 0, 0);
        pp.dwTo       = (sp.dwReturn << 8) | track;
        pp.dwCallback = _Form.Handle;
        ret           = Mci.Play(_DeviceID, Mci.MCI_PLAY, Mci.MCI_NOTIFY | Mci.MCI_FROM | Mci.MCI_TO, ref pp);
        if (ret != 0)
        {
            game_engine.Con_DPrintf("CDAudio: MCI_PLAY failed ({0})\n", ret);
            return;
        }

        _IsLooping = looping;
        _PlayTrack = track;
        _IsPlaying = true;

        if (_Volume == 0)
        {
            Pause();
        }
    }