Welcome Guest ( Log In | Register )

Bump Topic Topic Closed RSS Feed

Outline · [ Standard ] · Linear+

.NET How do you eject / play audio CD?

views
     
TSFlierMate
post Apr 13 2021, 11:22 AM, updated 3y ago

On my way
****
Validating
543 posts

Joined: Nov 2020
I made myself a DLL for sending MCI command string....

user posted image

CODE
using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace CD
{
   public partial class Form1 : Form
   {
       [DllImport(@"C:\.....\DLL\CDTRAY\CDTRAY.DLL")]
       private static extern void Eject();

       [DllImport(@"C:\....\DLL\CDTRAY\CDTRAY.DLL")]
       private static extern void Play();

       [DllImport(@"C:\...\DLL\CDTRAY\CDTRAY.DLL")]
       private static extern void Stop();

.....
.....

       private void button1_Click(object sender, EventArgs e)
       {
           Eject();
       }

       private void button2_Click(object sender, EventArgs e)
       {
           Play();
       }

....
.....


How do we do it in .NET? Is there any easier way? Currently I am building a DLL using another language to be referenced from .NET program.

BTW, every time I close the program, the CD would stopped playing, even I did not click Stop button.


cikelempadey
post Apr 13 2021, 02:11 PM

Getting Started
**
Junior Member
86 posts

Joined: Apr 2011
From: Your Nen Nen


u might as well use Windows multimedia API or DeviceIoControl API function directly inside your .net program instead of using another DLL.

QUOTE
BTW, every time I close the program, the CD would stopped playing, even I did not click Stop button.
of course it will stop playing coz ur program already closed. ur program needs to run, executing the code that is playing whatever it is.
TSFlierMate
post Apr 13 2021, 02:40 PM

On my way
****
Validating
543 posts

Joined: Nov 2020
QUOTE(cikelempadey @ Apr 13 2021, 02:11 PM)
u might as well use Windows multimedia API or DeviceIoControl API function directly inside your .net program instead of using another DLL.

*
I thought something easier like System.Media but it only supports playback of .WAV file. (sigh)

user posted image

I looked up DeviceIoControl and it is so complicated. sweat.gif

Anyway, thanks for the tips.

Topic ClosedOptions
 

Change to:
| Lo-Fi Version
0.0138sec    0.47    5 queries    GZIP Disabled
Time is now: 28th March 2024 - 09:11 PM