Overview
This script makes it so you can double-click music albums to listen to them.
Here's a short video showing what the script does and how it is configured. (The video is narrated, with optional subtitles.)
The script works by changing what double-click does when in thumbnails mode for specific folders (which you can configure).
To play the album, the script searches the for an .m3u playlist within the folder you double-clicked.
Since this only affects thumbnails mode, the script can be left enabled and your album folders can still be entered and managed in details mode.
Double-clicks will enter folders normally if you are not in thumbnails mode, or if you are not in one of the configured folders, or if no playlist is found within the folder you double-click.
Installation:
- Go to Preferences / Toolbars / Scripts.
- If you had the original v1.0 installed, select it and delete it.
- Download AlbumDoubleClick.vbs.txt (3.39 KB)
- Drag AlbumDoubleClick.vbs.txt to the list of scripts.
Usage:
Once installed, select the script in Preferences and click the Configure button. You'll see a list of script settings, although there is only one called AlbumFolders for this script.
Double-click the AlbumFolders line to edit that setting.
By default, it's set to these two folders:
Those are the folders where the script will change what double-click does. You can add or remove folders from the list as you wish. As you can see from the defaults, using aliases like /profile
is allowed.
Click OK in both dialogs, and don't forget to click OK or Apply in the main Preferences dialog (your script config changes won't be saved until you do that).
History:
v1.2 (20-Jan-2016):
- Now looks for both .m3u and .m3u8 files, to support Unicode playlists.
v1.1 (01-Oct-2015):
- Script will no longer affect middle-mouse double-clicks and double-clicks while holding Shift, Ctrl or Alt.
(Change requires Opus 11.16.1 or above.)
v1.0 (14-Feb-2014):
- Initial version.
The script itself:
If you just want to use the script, the AlbumDoubleClick.vbs.txt download above is all you need.
The script code is reproduced here to make it easier for people browsing the forum for scripting techniques.
Option Explicit
' Album Double-Click
' (c) 2014-2016 Leo Davidson
'
' This is a script for Directory Opus.
' See http://www.gpsoft.com.au/redirect.asp?page=scripts for development information.
'
' This script makes it so double-clicking a music album folder thumbnail will play the album
' instead of entering the folder.
'
' It works by changing what double-click does when in thumbnails mode for specific folders
' (which you can configure). To play the album, it searches the for an .m3u playlist within
' the folder you double-clicked.
'
' Since this only affects thumbnails mode, the script can be left enabled and your album
' folders can still be managed in details mode normally, while Opus turns into a music
' selection UI when you switch to thumbnails mode in the chosen folders.
' Called by Directory Opus to initialize the script
Function OnInit(initData)
' Provide basic information about the Script
initData.name = "Album Double-Click"
initData.version = "1.2"
initData.desc = "Double-click music album thumbnails to play them"
initData.copyright = "(c) 2014-2016 Leo Davidson"
initData.default_enable = true
Dim vecDefFolders
Set vecDefFolders = DOpus.NewVector
' Default folders / example config.
vecDefFolders.push_back("/profile\Music")
vecDefFolders.push_back("D:\Audio\Music Albums")
initData.config.AlbumFolders = vecDefFolders
initData.config_desc = DOpus.Create.Map("AlbumFolders", "List of folders the script should affect.")
End Function
' Helper Function
Function IsPathInVector(fsu, path, vecFolders)
IsPathInVector = False
' Resolve aliases, libraries, etc. to their real/absolute paths.
path = fsu.Resolve(path)
Dim testPath
For Each testPath in vecFolders
If (fsu.ComparePath(path, fsu.Resolve(testPath))) Then
IsPathInVector = True
Exit Function
End If
Next
End Function
' Called on double-click.
Function OnDoubleClick(doubleClickData)
' Don't change anything if we're not in thumbnails mode.
If (doubleClickData.tab.format.view <> "thumbnails") Then
Exit Function
End If
' Only affect left button double-clicks, with no qualifiers held down.
If (doubleClickData.mouse <> "left" Or doubleClickData.qualifiers <> "none") Then
Exit Function
End If
' Cache the FSUtil object, for efficiency.
Dim fsu
Set fsu = DOpus.FSUtil
' Don't change anything if we're not in one of the configured folders.
If (Not IsPathInVector(fsu, doubleClickData.tab.Path, Script.config.AlbumFolders)) Then
Exit Function
End If
' Don't change anything if the double-clicked item is not a folder.
If (Not doubleClickData.item.is_dir) Then
Exit Function
End If
' Look for a .M3U or .M3U8 file below the folder.
Dim folderEnum
Set folderEnum = fsu.ReadDir(doubleClickData.item, false)
Dim childItem
Do While (Not folderEnum.Complete)
Set childItem = folderEnum.Next
' Check for a .m3u extension. This also has the effect of ignoring folders,
' since folders always have an empty extension property (even if they
' have a name containing a dot), so we don't have to check that separately.
If (childItem.ext = ".m3u" or childItem.ext = ".m3u8") Then
' Launch the .m3u file we found.
DOpus.NewCommand.RunCommand """" & childItem & """"
' Prevent the standard double-click action.
OnDoubleClick = True
Exit Function
End If
Loop
End Function