Author Topic: Adding files to the playlist from the command line  (Read 10049 times)

Timo

  • Posts: 1
I guess the title of the thread says it all. You can open files from the command line, but can you add them to the playlist? I know there's an option so that all opened files are added to the playlist, but I don't want to use it.

Ian @ un4seen

  • Administrator
  • Posts: 18804
Re: Adding files to the playlist from the command line
« Reply #1 on: 31 Jan '07 - 17:57 »
Nope, I'm afraid not. Currently, the only way is to use DDE (command="[list(filename)]") or enable the "Add tracks to list" option.

nod5

  • Guest
Re: Adding files to the playlist from the command line
« Reply #2 on: 20 Aug '08 - 21:14 »
Can someone give a more detailed example on how to send that DDE command?
Say that I want to add the file C:\music\file.mp3
Do I need to use it in combination with some of the regular key+number DDE commands, as described on this page
http://support.xmplay.com/article.php?id=17

Alternatively, are there any key+number DDE commands for enabling/disabling the "add tracks to list" option? If there is, then we could send enable command, add files through command line and then send disable command.

Alternatively, how about the old request about some way to add tracks through command line. It would be the simplest way :-)

Dotpitch

  • Posts: 2814
Re: Adding files to the playlist from the command line
« Reply #3 on: 20 Aug '08 - 22:43 »
I think we've discussed that some time ago... (actually, about a year ago in this thread).

DDE is just a way of communicating between programs, so you'll need a program to send the messages to XMPlay. Tsorovan posted a fixed version of DDE_run here, a program that is operated from the commandline to send DDE commands to any other program.

Code: [Select]
DDE_run usage:
-s  Specify service name
-t  Specify topic
-n  Specify the name of program to run if connection fails
-c  Specify command to execute on server. Up to 10 allowed.

In this case, the service is XMPlay, the topic is System, the program is your xmplay.exe (with full path) and the command is the command you want to issue to XMPlay.
For example:
Code: [Select]
DDE_run -s XMPlay -t System -n "c:\program files\xmplay\xmplay.exe" -c key80This will send key80 to XMPlay (play/pause), or launch xmplay.exe if it's can't find a running XMPlay. You can add files to XMPlays playlist by using the command [list(%file%)], or open files with [open(%file%)] and replace the current playlist, where %file% is the full filepath and filename. You can send one file at a time.

Note that DDE is an outdated system (it was introduced in Windows 2.0 in 1987), so I'm not sure how long it'll stay around.

nod5

  • Guest
Re: Adding files to the playlist from the command line
« Reply #4 on: 21 Aug '08 - 22:05 »
Thanks! I made a small tool autohotkey that handles the adding. The .exe and source (.ahk) are attached as a zip in the following thread: http://www.donationcoder.com/Forums/bb/index.php?topic=7832.msg125469#msg125469

;-----------------------------------
; autohotkey script for silently adding to Xmplay playlist through DDE
;  takes file(s)/folder(s)/playlist(s) as input parameter
; - drop input on AHK_xmplay_input_to_playlist_DDEML.exe or
; - pass input as quote enclosed, space separated command line parameters
;  (use no end slash for folders!)
;   example: C:\AHK_xmplay_input_to_playlist_DDEML.exe "C:\musicfolder" "C:\music2\song.mp3"
;
; made by nod5
; using DDEML by sean, http://www.autohotkey.com/forum/topic19169.html
;-----------------------------------

amit

  • Posts: 721
Re: Adding files to the playlist from the command line
« Reply #5 on: 22 Aug '08 - 01:14 »
Thanks. It helps a lot.

Can you make another one which plays files instantly instead of adding them to the playlist?

nod5

  • Guest
Re: Adding files to the playlist from the command line
« Reply #6 on: 22 Aug '08 - 10:41 »
Amit, If you mean that the files should replace the previous playlist and then play, then just use the command line support built into Xmplay: http://support.xmplay.com/article.php?id=35

"c:\XMPlay.exe" "c:\Music\Garbage - Supervixen.ogg"

amit

  • Posts: 721
Re: Adding files to the playlist from the command line
« Reply #7 on: 23 Aug '08 - 14:14 »
I have tried a few times adding a button to totalcmd to play/add files in xmplay. I only succeeded adding them with your new tool. I thought it might be fairly easy to change the DDE command to play instead of add and recompile it.

I don't have the knowledge to do so hence my request from you :)

nod5

  • Guest
Re: Adding files to the playlist from the command line
« Reply #8 on: 24 Aug '08 - 01:40 »
just to be clear, do you ask for
1. to add tracks to the playlist without replacing previous playlist tracks and then start playing or
2. to add tracks to the playlist replacing previous playlist tracks and then start playing

I 1, then I can make a command line switch for it.
If 2, then the built in xmplay feature can already do that, just make sure to set it up correctly. If you can set up a button to pass command line parameters to my tool then the same should be possible for xmplay.
example:
my tool: C:\AHK_xmplay_input_to_playlist_DDEML.exe %1
xmplay: C:\program files\xmplay\xmplay.exe %1
(where %1 would be some variable; maybe not %1 in totalcmd but something like that I suppose)

amit

  • Posts: 721
Re: Adding files to the playlist from the command line
« Reply #9 on: 24 Aug '08 - 09:55 »
I am reffering to the second option: replacing the current playlist and play.

The command line doesn't work for me. not even in the most basic way : "path\xmplay.exe" "path\file.ext"

nod5

  • Guest
Re: Adding files to the playlist from the command line
« Reply #10 on: 24 Aug '08 - 14:08 »
You must be doing something wrong - that command line option works perfectly fine. Maybe you're missing a quote somewhere?

To change the DDE command in my script do this:
1. edit .ahk script source: replace "[list" with "[open" .
2. save and recompile (install autohotkey, right click .ahk, select "compile", done)

It will however then NOT work as it should if you use it with both files and a folder as input. Only the files or the folder - not both - will be played.

amit

  • Posts: 721
Re: Adding files to the playlist from the command line
« Reply #11 on: 24 Aug '08 - 15:59 »
Thanks. I will try it.

amit

  • Posts: 721
Re: Adding files to the playlist from the command line
« Reply #12 on: 24 Aug '08 - 20:39 »
By using %P%S parameters in Totalcmd it works perfectly , even when selecting folders and files together .

If its OK with you nod5 and there are no copyright issues I can upload it here .

nod5

  • Guest
Re: Adding files to the playlist from the command line
« Reply #13 on: 27 Aug '08 - 16:13 »
I'm glad that it works! Sure, you are free to modify and use the parts of the script that I wrote in any way for for any purpose. You could perhaps post it with a somewhat changed filename to avoid confusion and also post the source for those that prefer to compile by themselves. The DDEML function is from @ autohotkey forums btw, so anyone makling something proprietary using that might need permission from him. Very unlikely in this context though.

nod5

  • Guest
Re: Adding files to the playlist from the command line
« Reply #14 on: 27 Aug '08 - 16:15 »
I lost a word above. It should've been: "DDEML function is from Sean @ autohotkey forums "

amit

  • Posts: 721
Re: Adding files to the playlist from the command line
« Reply #15 on: 29 Aug '08 - 17:19 »
Here is the modification for the small dde command line tool nod5 has kindly created. It works similarly to  the original but instead of adding files to playlist it replaces the playlist with new files and plays them.

It is created with AutoHotKey script.

In the zip file you will find the compiled dde tool ("AHK_xmplay_replace_playlist_DDEML\AHK_xmplay_replace_playlist_DDEML.exe") and its source.

nod5

  • Posts: 1
Re: Adding files to the playlist from the command line
« Reply #16 on: 30 Aug '08 - 08:41 »
Nice!
Though, I get the problem I described earlier: if I select a few audio files and also a subfolder (with more audio files) the changed script then doesn't put all of them on the list.

example: imagine I have these files

C:\music\file1.mp3
C:\music\file2.mp3
C:\music\file3.mp3
C:\music\subfolder\file4.mp3
C:\music\subfolder\file5.mp3

If I then drag and drop

C:\music\file1.mp3
C:\music\file2.mp3
C:\music\file3.mp3
C:\music\subfolder\

onto the modded script, it then first clears the playlist, then adds file4-file5 but then immediately after that clears the playlist again and adds and plays file1-3. This is caused by the script using a temporary .pls file to speed things up and .pls files doesn't seem to support including folders so I had to let the script add folders as a separate step.

If it somehow works for you even in these cases then I'm happy though puzzled  :)

amit

  • Posts: 721
Re: Adding files to the playlist from the command line
« Reply #17 on: 30 Aug '08 - 10:09 »
I am using totalcmd with the parameters %P%S. These parameters send the full path and filenames (when there are spaces it adds quotation marks) of selected items. I think that choosing a folder sends actually the sub-folder resident filenames instead of the folder path itself. That is why when mixing folders and files together in this situation cause no problem.

Tsorovan

  • Posts: 1247
Re: Adding files to the playlist from the command line
« Reply #18 on: 9 Jul '09 - 20:32 »
[I'm an idiot, hadn't updated the locate32 database today]
« Last Edit: 9 Jul '09 - 20:53 by Tsorovan »