Могу ли я указать mpd добавить песню, воспроизводимую в данный момент, в определенный список воспроизведения?

Когда Вы смотрите на dmesg вывод для этого устройства Вы должны быть направлены к устройству. Из документов, на которые @yoonix сослался в комментариях:

автопогрузчик

$ dmesg | grep -A 2 "1x8 G2 AUTOLDR"    
Vendor: HP Model: 1x8 G2 AUTOLDR  
Rev: kn7B nl  Type:  
Medium Changer ANSI SCSI revision: 03 nl  3:0:0:0:  
Attached scsi generic sg2 type 8 

лента

$ dmesg | grep -A 4 "Ultrium"
Vendor: HP Model: Ultrium 3-SCSI  
Rev: kn7B    
Type: Sequential-Access ANSI SCSI revision: 03  
4:0:0:0: Attached scsi generic sg2 type 1    
st: version 20050830, fixed bufsize 32768, s/g segs 256    
st 4:0:0:0: Attached scsi tape st0 

Так как Вы получаете доступ к автопогрузчику на /dev/sg2 Я попробовал бы эту команду, чтобы подтвердить, что лента определяется:

$ mtx -f /dev/sg2 status
Storage Changer /dev/sg2:1 Drives, 9 Slots ( 1 Import/Export )    
Data Transfer Element 0:Empty   
Storage Element 1:Full :VolumeTag=64258F41    
Storage Element 2:Full :VolumeTag=64258F42    
Storage Element 3:Full :VolumeTag=64258F43    
Storage Element 4:Full :VolumeTag=64258F44    
Storage Element 5:Full :VolumeTag=64258F45    
Storage Element 6:Empty    
Storage Element 7:Empty   
Storage Element 8:Empty    
Storage Element 9 IMPORT/EXPORT:Empty   

Но это должен, вероятно, быть любой дескриптор, упоминается в выводе от dmesg.

hwinfo

Вы могли также выполнить эту команду, hwinfo получить больше информации о ленточном накопителе.

$ hwinfo --tape
89: SCSI 00.0: 10601 Tape
[Created at scsi.1460]
UDI: /org/freedesktop/Hal/devices/pci_103c_323a_scsi_host_scsi_device_lun0_scsi_gene ric
Unique ID: Er1e.jH5QXkQpQf6
Parent ID: GBI1.XEXEELn_ra7
SysFS ID: /class/scsi_tape/st0
SysFS BusID: 0:0:0:0
SysFS Device Link: /devices/pci0000:00/0000:00:03.0/0000:08:00.0/host0/target0:0:0/0:0:0:0
Hardware Class: unknown
Model: "HP Ultrium 4-SCSI"
Vendor: "HP"
Device: "Ultrium 4-SCSI"
Revision: "U57D"
Driver: "cciss", "st"
Driver Modules: "cciss"
Device File: /dev/st0 (/dev/sg0)
Device Files: /dev/st0, /dev/char/9:0, /dev/tape/by-id/scsi-3500110a001465016, /dev/tape/by-path/pci-0000:08:00.0-scsi-0:0:0:0
Device Number: char 9:0 (char 21:0)
Config Status: cfg=new, avail=yes, need=no, active=unknown
Attached to: #61 (RAID bus controller)mt command out puts

Источник: https://forums.suse.com/archive/index.php/t-1510.html

2
07.05.2015, 18:44
2 ответа

Просто нажатие «A» в NCMPCPP приведет к экрану, в котором вы можете выбрать плейлист, чтобы добавить в данный момент (или выбранный) элемент.

3
27.01.2020, 22:05

Это добавит текущую воспроизводимую песню в список воспроизведения, определенный в коде. Требуется libmpdclient.

  1. отредактируйте приведенный ниже код с вашими определениями и сохраните в файл (, например. добавить -в -mpd -playlist.c)
  2. gcc или clang с флагом lmpdclient (например. clang добавить -в -mpd -playlist.c -o добавить -в -mpd -плейлист -lmpdclient)
  3. запустить двоичный файл (например../добавить -в -mpd -плейлист)

Дальнейшие улучшения включают разрешение аргументов и/или файла конфигурации для хоста, порта, прохода, списка воспроизведения. libmpdclient doc — ваш друг.

#include <stdio.h>
#include <mpd/client.h>

//D(x) function for debug messages
//#define DEBUG
#ifdef DEBUG
#define D(x) do { x; } while(0)
#else
#define D(x) do { } while(0)
#endif

#define HOST "YOUR_HOSTNAME"
#define PORT YOUR_PORTNUMBER //usually it's 6600
#define PASS "YOUR_PASSWORD" //comment out if no password
#define PLAYLIST "PLAYLIST_NAME_TO_ADD_CURRENT_SONG_TO"

struct mpd_connection* conn(){
    D(printf("%s %s\n","Connecting to",HOST));
    const char* host = HOST;
    unsigned port = PORT;
    struct mpd_connection* c = mpd_connection_new(host,port,0);

    enum mpd_error err = mpd_connection_get_error(c);
    if(err != 0){
        printf("Error code: %u. View error codes here: https://www.musicpd.org/doc/libmpdclient/error_8h.html\n",err);
        return 0;
    }

    #ifdef PASS
    const char* pass = PASS;
    if(mpd_run_password(c,pass) == false){
        printf("%s\n","Bad password");
        return 0;
    }
    #endif

    D(printf("%s %s\n","Connected to",HOST));
    return c;
}


int main(){
    struct mpd_connection* c = conn();
    if(c == 0) return -1;

    struct mpd_song* curr = mpd_run_current_song(c);
    const char* curr_uri = mpd_song_get_uri(curr);
    D(printf("Currently playing: %s\n",curr_uri));

    if(mpd_run_playlist_add(c,PLAYLIST,curr_uri)){
        printf("%s %s %s %s\n","Added",curr_uri,"to playlist",PLAYLIST);
    }
    else{
        printf("%s\n","Some error");
        return -1;
    }

    return 0;
}

Я добавил несколько проверок и немного отладки; делай с кодом как хочешь.

0
27.01.2020, 22:05

Теги

Похожие вопросы