Home of the Squeezebox™ & Transporter® network music players.
Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15
  1. #11
    Senior Member
    Join Date
    Mar 2014
    Posts
    222
    It work thanks ! I didn't have this plugin.

    Let's go testing CLI now

    Sent from my ONEPLUS A3003 using Tapatalk

  2. #12
    Senior Member
    Join Date
    Mar 2014
    Posts
    222
    First question, on a server plugin, how did you get the library ?

    I use this code to get informations for a player :

    Code:
    sub handlePlayTrack {
    
                    my $client = shift;
    
                    my $iSyncedPlayer = $client->isSynced() ;
    
                    my $iPower = $client->power();
    
                    my $iMaster = Slim::Player::Sync::isMaster($client);
    
                    my @iSyncedMaster = $client->master() ;
    
                    my $iSyncedGroup = "";
    
                    my @SyncedSlaves ;
    
                    my $sTitle = $client->playingSong();
    
                    my $sName =  'Vide';    
    
                    my $artist   = 'Vide';
    
                    my $artist_id   = 'null';
    
                    my $album    = 'Vide';
    
                    my $album_id    = 'null';
    
                    my $id    = 'null';
    
                    my $cover = 'null';
    
                    my $duration =  0;
    
                    my $played =  0;
    
                    my $iVolume = $client->volume();
    
                    my $player_name = $client->name();
    
                    $log->debug('handlePlayTrack for '.$player_name);
    
                    my $player_model = $client->modelName();
    
                    my $player_ip = $client->ip();
    
                    my $status = ' ';
    
                    my $sync_status = 0;
    
                    my $repeat_status = Slim::Player::Playlist::repeat($client);
    
                    my $shuffle_status = Slim::Player::Playlist::shuffle($client);
    
                    my $mac = ref($client) ? $client->macaddress() : $client;
    
                    if(defined($sTitle)) {
    
                        eval {$sName =  $sTitle->track()->title  || ''; }; warn $@ if $@;
    
                        eval {$id =  $sTitle->track()->id  || '';   }; warn $@ if $@;
    
                        eval { $artist   = $sTitle->track()->artistName || '';}; warn $@ if $@;
    
                        eval { $artist_id   = $sTitle->track()->artistid || '';}; warn $@ if $@;
    
                        eval { $album    = $sTitle->track()->album  ? $sTitle->track()->album->name  : '';}; warn $@ if $@;
    
                        eval { $album_id    = $sTitle->track()->albumid || '';}; warn $@ if $@;      
    
                        eval { $duration = $sTitle->track()->secs;}; warn $@ if $@;
    
                        $cover = 'music/current/cover.jpg?player='.$mac.'&album_id='.$album_id;
    
                        $artist     = encode('UTF-8', $artist);
    
                        $album     = encode('UTF-8', $album);
    
                        $sName     = encode('UTF-8', $sName);
    
                        my $remoteMeta;
    
                        my $handler;
    
                        $handler = Slim::Player::ProtocolHandlers->handlerForURL($sTitle->track()->url);
    
                        if ( $handler && $handler->can('getMetadataFor') ) {
    
                            $remoteMeta = $handler->getMetadataFor($client,$sTitle->track()->url );
    
                            $cover = 'music/current/cover.jpg?player='.$mac.'&'.rand();
    
                            $album = $sName;
    
                            if(defined( $remoteMeta->{album})) {
    
                                $album = encode('UTF-8', $remoteMeta->{album});
    
                            }
                            
                            $artist = encode('UTF-8', $remoteMeta->{artist});
    
                            $sName = encode('UTF-8', $remoteMeta->{title});
    
                            $artist_id = "null";
    
                            $album_id = "null";
    
                        }
    
                        $played = Slim::Player::Source::songTime($client);
    
                    }
    
                    my $remaining = $duration - $played;
    
                    my $iPaused = $client->isPaused();
    
                    my $iStopped = $client->isStopped();
    
                    my $lifetime = 0;
    
                    my $type = "PlayerInformations";
    
                    if($iPower ==  1) {
    
                        if($iPaused ne  1) {
    
                            if ($iStopped == 1){
    
                                $status = "Stop";
                                $lifetime = 0;
    
                                }else{
    
                                    $status = "Lecture"; 
                                    $volume = $iVolume;
                                    $lifetime = roundup($remaining);
    
                                }
    
                                }else{
    
                                    $status = "Pause";
                                    $lifetime = 0;
    
                                } 
    
                                }else{
    
                                    $status = "Off";
                                    $lifetime = 0;
    
                                }
    
                                if ($iSyncedPlayer ==1 ){
    
                                    $sync_status = 1;
    
                                    @SyncedSlaves = Slim::Player::Sync::slaves($client);
    
                                    my $slave_json;
    
                                    my $macmaster;
    
                                    my $master_name;
    
                                    foreach my $slaveclient (@SyncedSlaves) {
    
                                        my $macslave = ref($slaveclient) ? $slaveclient->macaddress() : $slaveclient;
    
                                        my $slave_name = $slaveclient->name();
    
                                        $slave_json .= "{name:\"$slave_name\",mac:\"$macslave\"},";  
    
                                    }
    
                                    foreach my $masterclient (@iSyncedMaster) {
    
                                        $macmaster = ref($masterclient) ? $masterclient->macaddress() : $masterclient;
    
                                        $master_name = $masterclient->name();
    
                                        my $volume = $masterclient->volume();
    
                                        my $player_model = $masterclient->modelName();
    
                                        my $player_ip = $masterclient->ip();
    
                                        &sendToConstellation ( $master_name, "{name:\"$master_name\",mac:\"$macmaster\",ip:\"$player_ip\",model:\"$player_model\",repeat:$repeat_status,shuffle:$shuffle_status,data:{title:\"$sName\",title_id:$id,artist:\"$artist\",artist_id:$artist_id,album:\"$album\",album_id:$album_id,cover:\"$cover\",duration:$duration,remaining:$remaining,statut:\"$status\",volume:$volume,sync:{master:null,slave:[$slave_json]}}}",$lifetime,$type);
    
                                    } 
    
                                    foreach my $slaveclient (@SyncedSlaves) {
    
                                        my $macslave = ref($slaveclient) ? $slaveclient->macaddress() : $slaveclient;
    
                                        my $slave_name = $slaveclient->name();
    
                                        my $volume = $slaveclient->volume();
    
                                        my $player_model = $slaveclient->modelName();
    
                                        my $player_ip = $slaveclient->ip();
    
                                        &sendToConstellation ( $slave_name, "{name:\"$slave_name\",mac:\"$macslave\",ip:\"$player_ip\",model:\"$player_model\",repeat:$repeat_status,shuffle:$shuffle_status,data:{title:\"$sName\",title_id:$id,artist:\"$artist\",artist_id:$artist_id,album:\"$album\",album_id:$album_id,cover:\"$cover\",duration:$duration,remaining:$remaining,statut:\"$status\",volume:$volume,sync:{master:{name:\"$master_name\",mac:\"$macmaster\"},slave:[$slave_json]}}}",$lifetime,$type);
    
                                    }
    
                                    }else{
    
                                       $log->debug('handlePlayTrack2');
    
                                       &sendToConstellation ( $player_name, "{name:\"$player_name\",mac:\"$mac\",ip:\"$player_ip\",model:\"$player_model\",repeat:$repeat_status,shuffle:$shuffle_status,data:{title:\"$sName\",title_id:$id,artist:\"$artist\",artist_id:$artist_id,album:\"$album\",album_id:$album_id,cover:\"$cover\",duration:$duration,remaining:$remaining,statut:\"$status\",volume:$volume,sync:null}}",$lifetime,$type);
    
                                   }
                               }
    
                               sub commandCallbackPlayers {
    
                                my @players = Slim::Player::Client::clients();
    
                                my $informations;
    
                                my $info;
    
                                my $lifetime = 0;
    
                                my $type = "PlayersList";
    
                                my $player_connect = 0;
    
                                foreach my $client (@players) {
    
                                    my $client_connect = $client->connected();
    
                                    if($client_connect ==1){
    
                                       $player_connect++;
    
                                       my $client_name = $client->name();
    
                                       $client_name = encode('UTF-8', $client_name);   
    
                                       my $client_mac = ref($client) ? $client->macaddress() : $client; 
    
                                       $informations .= "{name:\"$client_name\",mac:\"$client_mac\"},";  
    
                                       &handlePlayTrack($client);
    
                                       $data{$client_name} = '';
    
                                   }
                               }
    
    
                               $info = "{players_connect:$player_connect,players:[" . $informations . "]}";
    
                               if($player_connect == 0) {
    
    
                                $info = "{players_connect:0,players:null}";
    
    
                                &sendToConstellation ( "Players", $info, 0, $type);
    
    
                                }else{
    
                                   $informations .= ']}';
                                   &sendToConstellation ( "Players", $informations, $lifetime, $type);
    
                               }
    
    
    
                           }

  3. #13
    Senior Member
    Join Date
    Apr 2008
    Location
    Paris, France
    Posts
    2,165
    3 SB 3 • Libratone Loop, Zipp Mini • iPeng (iPhone + iPad) • LMS 7.9 (linux) with plugins: CD Player, WaveInput, Triode's BBC iPlayer by bpa • IRBlaster by Gwendesign (Felix) • Server Power Control by Gordon Harris • Smart Mix, Music Walk With Me, What Was That Tune? by Michael Herger • PowerSave by Jason Holtzapple • Song Info, Song Lyrics by Erland Isaksson • AirPlay Bridge by philippe_44 • WeatherTime by Martin Rehfeld • Auto Dim Display, SaverSwitcher, ContextMenu by Peter Watkins.

  4. #14
    Senior Member
    Join Date
    Mar 2014
    Posts
    222
    Yes you get the library id with CLI but inside a server plugin ?

    Sent from my ONEPLUS A3003 using Tapatalk

  5. #15
    Babelfish's Best Boy mherger's Avatar
    Join Date
    Apr 2005
    Location
    Switzerland
    Posts
    19,866

    Multi library and cli

    > Yes you get the library id with CLI but inside a server plugin ?

    I think I should start to refer to the commands differently than CLI.
    It's misleading. Those commands are being used internally, too, of
    course. Look into some code doing eg. $client->execute(). That method
    would accept all those "CLI" commands. What you're looking for (and
    basically re-implemented) is the "status" query.

    --

    Michael

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •