Skip to content

Commit

Permalink
Merge MP1-4803
Browse files Browse the repository at this point in the history
Squashed commit of the following:

commit 75b4686
Author: mm1352000 <music_man1352000@yahoo.com.au>
Date:   Fri May 27 13:58:46 2016 +1200

    Fix problem 3: ACTION_CDEJECT doesn't act on the selected drive in the videos, pictures or music plugins.

    This problem was caused by a design limitation (ACTION_CDEJECT handled exclusively in main class WndProc()). Design changed to have videos, music and pictures plugins handle ACTION_CDEJECT, and the main class only handles it when those windows are not active.

commit 17bf16d
Author: mm1352000 <music_man1352000@yahoo.com.au>
Date:   Fri May 27 13:49:26 2016 +1200

    Fix problem 2: the "eject" context menu item in the music and pictures plugins doesn't work when the drive does not contain a disc.

    The eject context menu item was trying to be too clever, closing the tray when it was open and opening the tray when it was closed. Actually, it's not possible (or very *very* difficult) to distinguish between "open tray" and "closed tray without disc". So, it's better to have the item simply open the tray as suggested by the item label.

commit 78fc361
Author: mm1352000 <music_man1352000@yahoo.com.au>
Date:   Fri May 27 13:37:26 2016 +1200

    Fix problem 1: ACTION_EJECTCD doesn't work.
    Calling EjectCDROM(string.Empty) does not have the intended effect because CreateFile(string.Empty...) returns INVALID_HANDLE_VALUE. So, ejecting the default disc drive needs a completely different implementation. mciSendString() - the previous implementation - is easy and seems to work well, so we use that.
  • Loading branch information
mm1352000 committed Jun 22, 2016
1 parent 168c2d3 commit 2302086
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 32 deletions.
2 changes: 1 addition & 1 deletion mediaportal/Core/Util/Util.cs
Expand Up @@ -2070,7 +2070,7 @@ public static bool EjectCDROM(string strDrive)

public static void EjectCDROM()
{
EjectCDROM(string.Empty);
mciSendString("set cdaudio door open", null, 0, IntPtr.Zero);
}

public static void CloseCDROM(string driveLetter)
Expand Down
7 changes: 6 additions & 1 deletion mediaportal/MediaPortal.Application/MediaPortal.cs
Expand Up @@ -4169,7 +4169,12 @@ private void OnAction(Action action)

// eject cd
case Action.ActionType.ACTION_EJECTCD:
Utils.EjectCDROM();
if (GUIWindowManager.ActiveWindow != (int)GUIWindow.Window.WINDOW_MUSIC_FILES &&
GUIWindowManager.ActiveWindow != (int)GUIWindow.Window.WINDOW_PICTURES &&
GUIWindowManager.ActiveWindow != (int)GUIWindow.Window.WINDOW_VIDEOS)
{
Utils.EjectCDROM();
}
break;

// Display Render statistic
Expand Down
29 changes: 16 additions & 13 deletions mediaportal/WindowPlugins/GUIMusic/GUIMusicFiles.cs
Expand Up @@ -580,6 +580,21 @@ public override void OnAction(Action action)
}
}

if (action.wID == Action.ActionType.ACTION_EJECTCD)
{
GUIListItem item = facadeLayout.SelectedListItem;
if (item == null || item.Path == null || Util.Utils.getDriveType(item.Path) != 5)
{
Util.Utils.EjectCDROM();
}
else
{
Util.Utils.EjectCDROM(Path.GetPathRoot(item.Path));
}

LoadDirectory(string.Empty);
}

base.OnAction(action);
}

Expand Down Expand Up @@ -1158,25 +1173,13 @@ protected override void OnShowContextMenu()
break;

case 654: // Eject
if (item != null && Util.Utils.getDriveType(item.Path) != 5)
if (item == null || item.Path == null || Util.Utils.getDriveType(item.Path) != 5)
{
Util.Utils.EjectCDROM();
}
else
{
if (item != null && item.Path != null)
{
var driveInfo = new DriveInfo(Path.GetPathRoot(item.Path));

if (!driveInfo.IsReady)
{
Util.Utils.CloseCDROM(Path.GetPathRoot(item.Path));
}
else
{
Util.Utils.EjectCDROM(Path.GetPathRoot(item.Path));
}
}
}
LoadDirectory(string.Empty);
break;
Expand Down
32 changes: 17 additions & 15 deletions mediaportal/WindowPlugins/GUIPictures/GUIPictures.cs
Expand Up @@ -647,6 +647,20 @@ public override void OnAction(Action action)
}
}
}
if (action.wID == Action.ActionType.ACTION_EJECTCD)
{
GUIListItem item = facadeLayout.SelectedListItem;
if (item == null || item.Path == null || Util.Utils.getDriveType(item.Path) != 5)
{
Util.Utils.EjectCDROM();
}
else
{
Util.Utils.EjectCDROM(Path.GetPathRoot(item.Path));
}

LoadDirectory(string.Empty);
}

base.OnAction(action);
}
Expand Down Expand Up @@ -1363,25 +1377,13 @@ protected override void OnShowContextMenu()
}
break;
case 654: // Eject
if (item != null && Util.Utils.getDriveType(item.Path) != 5)
if (item == null || item.Path == null || Util.Utils.getDriveType(item.Path) != 5)
{
Util.Utils.EjectCDROM();
}
else
{
if (item != null && item.Path != null)
{
var driveInfo = new DriveInfo(Path.GetPathRoot(item.Path));

if (!driveInfo.IsReady)
{
Util.Utils.CloseCDROM(Path.GetPathRoot(item.Path));
}
else
{
Util.Utils.EjectCDROM(Path.GetPathRoot(item.Path));
}
}
{
Util.Utils.EjectCDROM(Path.GetPathRoot(item.Path));
}
LoadDirectory(string.Empty);
break;
Expand Down
19 changes: 17 additions & 2 deletions mediaportal/WindowPlugins/GUIVideos/GUIVideoFiles.cs
Expand Up @@ -479,7 +479,22 @@ public override void OnAction(Action action)
{
_playClicked = true;
}


if (action.wID == Action.ActionType.ACTION_EJECTCD)
{
GUIListItem item = facadeLayout.SelectedListItem;
if (item == null || item.Path == null || Util.Utils.getDriveType(item.Path) != 5)
{
Util.Utils.EjectCDROM();
}
else
{
Util.Utils.EjectCDROM(Path.GetPathRoot(item.Path));
}

LoadDirectory(string.Empty);
}

base.OnAction(action);
}

Expand Down Expand Up @@ -1535,7 +1550,7 @@ protected override void OnShowContextMenu()
break;

case 654: // Eject
if (Util.Utils.getDriveType(item.Path) != 5)
if (item == null || item.Path == null || Util.Utils.getDriveType(item.Path) != 5)
{
Util.Utils.EjectCDROM();
}
Expand Down

0 comments on commit 2302086

Please sign in to comment.