January 2015
Beginner to intermediate
85 pages
1h 58m
English
We now have the playlist displayed in a window we can easily open. Let’s add the ability to play a specific song chosen by the user.
We’re going to create a new function, mpc#PlaySong, within our autoload directory. It will take the number of a song in the playlist—what mpc refers to as the song’s position—and send that number back to mpc using system. Add the following code to autoload/mpc.vim:
| autoload.1/mpc/autoload/mpc.vim | |
| Line 1 | function! mpc#PlaySong(no) |
| 2 | let song = split(getline(a:no), " ") |
| 3 | let results = split(system("mpc --format '%title% (%artist%)' play " |
| 4 | \ . song[0]), "\n") |
| 5 | let message = '[mpc] NOW PLAYING: ' . results[0] |
| 6 | echomsg message |
| 7 | endfunction |
There ...
Read now
Unlock full access