Esempio n. 1
0
void
ITunesScript::callback( CFDictionaryRef info )
{
    ITunesDictionaryHelper dict( info );
    State const previousState = m_state;
    m_state = dict.state;
    
    switch (m_state)
    {
        case Paused:
            transmit( "PAUSE c=osx\n" );
            break;

        case Stopped:
            transmit( "STOP c=osx\n" );
            break;
            
        case Playing:
            if (!isMusic())
            {
                qDebug() << "Ignoring current track because it isn't music.";
                break;
            }

            dict.determineTrackInformation();

            // if the track is restarted it has the same pid and a position of 0
            if (m_previousPid == dict.pid && dict.position != 0)
            {
                if (previousState == Paused)
                    transmit( "RESUME c=osx\n" );
                //else the user changed some metadata or the track's rating etc.
            }
            else
            {
                transmit( "START c=osx"
                               "&a=" + encodeAmp( dict.artist ) +
                               "&t=" + encodeAmp( dict.name ) +
                               "&b=" + encodeAmp( dict.album ) +
                               "&l=" + QString::number( dict.duration ) +
                               "&p=" + encodeAmp( dict.path ) + '\n' );

                m_previousPid = dict.pid;
            }
            break;

        default:
          qWarning() << "Unknown state.";
          break;
    }
}
Esempio n. 2
0
/**
 * helperfunction for scandir() - just return unhidden regular music files
 */
static int msel( const struct dirent *entry ) {
	return( ( entry->d_name[0] != '.' ) &&
			( entry->d_type == DT_REG ) &&
			isMusic( entry->d_name ) );
}