Play() private method

private Play ( IntPtr device, int cmd, int flags, PlayParams &p ) : int
device System.IntPtr
cmd int
flags int
p PlayParams
return int
Example #1
0
        public void Resume()
        {
            if (!_IsEnabled)
            {
                return;
            }

            if (!_IsValidDisc)
            {
                return;
            }

            if (!_WasPlaying)
            {
                return;
            }

            Mci.PlayParams 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)
            {
                Con.DPrint("CDAudio: MCI_PLAY failed ({0})\n", ret);
            }

            _IsPlaying = (ret == 0);
        }
Example #2
0
        public void Play(byte track, bool looping)
        {
            if (!_IsEnabled)
            {
                return;
            }

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

            track = _Remap[track];

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

            // don't try to play a non-audio track
            Mci.StatusParams sp = default(Mci.StatusParams);
            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)
            {
                Con.DPrint("MCI_STATUS failed ({0})\n", ret);
                return;
            }
            if (sp.dwReturn != Mci.MCI_CDA_TRACK_AUDIO)
            {
                Con.Print("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)
            {
                Con.DPrint("MCI_STATUS failed ({0})\n", ret);
                return;
            }

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

            Mci.PlayParams 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)
            {
                Con.DPrint("CDAudio: MCI_PLAY failed ({0})\n", ret);
                return;
            }

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

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