Adding Drag and Drop Functionality to AxMicrosoft.MediaPlayer.Interop.AxWindowsMediaPlayer

V

ViRi

I am wringing a small and lite Media Player to fit my custom needs for
usage while programming.

I had written some drag and drop functionality like i do with other
programs, but hey, the ActiveX doesn't support Drag and Drop. I've been
checking loads of search results, but no dice, no info on how to add
drag and drop to an activex that doesn't has it by default, or a hack
to get it to use the drag and drop of the form itself, or something
similar.

The drag&drop stuff i wrote (Get an unsupported error):


this.axWMP.DragDrop += new
System.Windows.Forms.DragEventHandler(axWMP_DragDrop);
this.axWMP.DragEnter += new
System.Windows.Forms.DragEventHandler(axWMP_DragEnter);

void axWMP_DragEnter(object sender,
System.Windows.Forms.DragEventArgs e)
{
if
(e.Data.GetDataPresent(System.Windows.Forms.DataFormats.FileDrop))
{
string[] files =
(string[])e.Data.GetData(System.Windows.Forms.DataFormats.FileDrop);
foreach (string s in files)
{
if (s.EndsWith(".avi") || s.EndsWith(".mpg") ||
s.EndsWith(".wmv"))
{
e.Effect =
System.Windows.Forms.DragDropEffects.Copy;
return;
}
}
}
else
{
e.Effect = System.Windows.Forms.DragDropEffects.None;
}
}

void axWMP_DragDrop(object sender,
System.Windows.Forms.DragEventArgs e)
{
//System.Windows.Forms.DataFormats.FileDrop
if
(e.Data.GetDataPresent(System.Windows.Forms.DataFormats.FileDrop))
{
string[] files =
(string[])e.Data.GetData(System.Windows.Forms.DataFormats.FileDrop);
try
{
foreach (string s in files)
{
if (s.EndsWith(".avi") || s.EndsWith(".mpg") ||
s.EndsWith(".wmv"))
{

axWMP.currentPlaylist.appendItem(axWMP.mediaCollection.getByName(s).get_Item(0));
}
}
}
catch (System.Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
return;
}
if (axWMP.playState !=
Microsoft.MediaPlayer.Interop.WMPPlayState.wmppsPlaying)
{
axWMP.Ctlcontrols.play();
}
}
}


On a different note: i also have a small question about the Alt-Enter
behaviour of this ActiveX, when in full screen modus, and you hit
alt-enter, it goes out of fullscreen modus, it does not respont to
other hotkey's, because of this matter, i cannot write support for the
alt-enter hotkey combo, because it will allow me to toggle into full
screen the first time, but after that, it will go out of, and directly
back into fullscreen again, other combo's work without a problem.


Thanks in advance,

Nick.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top