Exemplo n.º 1
0
TrackPtr
TrackManager::load
(const Ogre::String& name, const Ogre::String& group)
{
  // Obtención del recurso por nombre...
  TrackPtr trackPtr = getByName(name);
 
  // Si no ha sido creado, se crea.
  if (trackPtr.isNull()) 
    trackPtr = create(name, group);
 
  // Carga explícita del recurso.
  trackPtr->load();
 
  return trackPtr;
}
Exemplo n.º 2
0
void PlayQueueOverlays::ShowAlbumDividerOverlay(
    IMessageQueue& messageQueue, PlaybackService& playback, ILibraryPtr library, TrackPtr firstTrack)
{
    std::shared_ptr<Adapter> adapter(new Adapter());
    adapter->AddEntry(_TSTR("playqueue_overlay_album_jump_to"));
    adapter->AddEntry(_TSTR("playqueue_overlay_artist_jump_to"));
    adapter->AddEntry(_TSTR("playqueue_overlay_genre_jump_to"));
    adapter->AddEntry(_TSTR("playqueue_overlay_album_play"));
    adapter->AddEntry(_TSTR("playqueue_overlay_add_to_playlist"));
    adapter->AddEntry(_TSTR("playqueue_overlay_add_to_start_of_queue"));
    adapter->AddEntry(_TSTR("playqueue_overlay_add_to_end_in_queue"));
    adapter->AddEntry(_TSTR("playqueue_overlay_add_as_next_in_queue"));
    adapter->SetSelectable(true);

    std::shared_ptr<ListOverlay> dialog(new ListOverlay());

    dialog->SetAdapter(adapter)
        .SetTitle(_TSTR("playqueue_overlay_album_header_actions_title"))
        .SetWidth(_DIMEN("playqueue_album_header_overlay_width", DEFAULT_OVERLAY_WIDTH))
        .SetSelectedIndex(0)
        .SetItemSelectedCallback(
            [&playback, library, &messageQueue, firstTrack]
            (ListOverlay* overlay, IScrollAdapterPtr adapter, size_t index) {
            if (index == ListWindow::NO_SELECTION) {
                return;
            }

            auto albumColumn = library::constants::Track::ALBUM;
            auto albumId = firstTrack->GetInt64(library::constants::Track::ALBUM_ID);

            /* items 0, 1, and 2 jump to category */
            if (index <= 2) {
                handleJumpTo(index, messageQueue, firstTrack);
            }
            else if (index == 3) { /* replace play queue */
                std::shared_ptr<CategoryTrackListQuery> query(
                    new CategoryTrackListQuery(library, albumColumn, albumId));

                library->Enqueue(query, ILibrary::QuerySynchronous);

                if (query->GetStatus() == IQuery::Finished) {
                    playback.Play(*query->GetResult().get(), 0);
                }
            }
            /* add to playlist */
            else if (index == 4) {
                showAddCategorySelectionToPlaylistOverlay(
                    messageQueue, library, albumColumn, albumId);
            }
            /* the other are our standard play queue operations */
            else {
                handleAddCategorySelectionToPlayQueue(
                    playback, library, albumColumn, albumId, index - 5);
            }
    });

    cursespp::App::Overlays().Push(dialog);
}
Exemplo n.º 3
0
static void handleJumpTo(
    size_t index,
    IMessageQueue& messageQueue,
    TrackPtr track)
{
    int64_t type;
    int64_t id;

    if (index == 0) {
        type = cube::message::category::Album;
        id = track->GetInt64(library::constants::Track::ALBUM_ID);
    }
    else if (index == 1) {
        type = cube::message::category::Artist;
        id = track->GetInt64(library::constants::Track::ARTIST_ID);
    }
    else if (index == 2) {
        type = cube::message::category::Genre;
        id = track->GetInt64(library::constants::Track::GENRE_ID);
    }

    messageQueue.Broadcast(runtime::Message::Create(
        nullptr, cube::message::JumpToCategory, type, id));
}
void OpmlDirectoryInfoParser::getInfo( TrackPtr track )
{
    DEBUG_BLOCK
    showLoading( i18n( "Loading Podcast Info..." ) );

    OpmlDirectoryFeed * feed = dynamic_cast<OpmlDirectoryFeed *>( track.data() );

    if ( !feed ) return;

    debug() << "OpmlDirectoryInfoParser: getInfo about feed: " << feed->uidUrl();

    m_rssDownloadJob = KIO::storedGet( feed->uidUrl(), KIO::Reload, KIO::HideProgressInfo );
    The::statusBar()->newProgressOperation( m_rssDownloadJob, i18n( "Fetching Podcast Info" ) );
    connect( m_rssDownloadJob, SIGNAL(result(KJob *)), SLOT( rssDownloadComplete( KJob*) ) );
}
Exemplo n.º 5
0
void
JamendoInfoParser::getInfo(TrackPtr track)
{
    DEBUG_BLOCK
    JamendoTrack * jamendoTrack = dynamic_cast<JamendoTrack *> ( track.data() );
    if ( jamendoTrack == 0) return;

    QString infoHtml = "<HTML><HEAD><META HTTP-EQUIV=\"Content-Type\" "
                       "CONTENT=\"text/html; charset=utf-8\"></HEAD><BODY>";
    infoHtml +=        "<div align=\"center\">";
    infoHtml +=        i18n( "Track" ) + "<br><br>";
    infoHtml +=        "<strong>";
    infoHtml +=        jamendoTrack->prettyName();
    infoHtml +=        "</strong><br><br><em>";
    infoHtml +=        "<br><br>" + i18n( "From Jamendo.com" ) + "</div>";
    infoHtml +=        "</BODY></HTML>";

    emit( info( infoHtml ) );
}
Exemplo n.º 6
0
static void showAddTrackToPlaylistOverlay(
    IMessageQueue& queue, ILibraryPtr library, TrackPtr track)
{
    std::shared_ptr<CategoryListQuery> query = queryPlaylists(library);
    auto result = query->GetResult();

    std::shared_ptr<Adapter> adapter(new Adapter());
    adapter->SetSelectable(true);
    adapter->AddEntry(_TSTR("playqueue_overlay_new"));
    addPlaylistsToAdapter(adapter, result);

    size_t selectedIndex = 0;
    if (!lastOperationExpired() && lastPlaylistId >= 0) {
        int index = findPlaylistIndex(result, lastPlaylistId);
        if (index >= 0) {
            selectedIndex = (size_t) index + 1; /* +1 offsets "new..." */
        }
    }

    showPlaylistListOverlay(
        _TSTR("playqueue_overlay_select_playlist_title"),
        adapter,
        [library, track, &queue, result]
        (ListOverlay* overlay, IScrollAdapterPtr adapter, size_t index) {
            if (index != ListWindow::NO_SELECTION) {
                std::shared_ptr<TrackList> list(new TrackList(library));
                list->Add(track->GetId());

                if (index == 0) { /* new playlist */
                    createNewPlaylist(queue, list, library);
                }
                else { /* add to existing */
                    int64_t playlistId = (*result)[index - 1]->GetId();
                    setLastPlaylistId(playlistId);
                    library->Enqueue(SavePlaylistQuery::Append(library, playlistId, list), 0);
                }
            }
        },
        selectedIndex);
}
Exemplo n.º 7
0
void PlayQueueOverlays::ShowAddTrackOverlay(
    IMessageQueue& messageQueue,
    ILibraryPtr library,
    PlaybackService& playback,
    TrackPtr track)
{
    std::shared_ptr<Adapter> adapter(new Adapter());
    adapter->AddEntry(_TSTR("playqueue_overlay_album_jump_to"));
    adapter->AddEntry(_TSTR("playqueue_overlay_artist_jump_to"));
    adapter->AddEntry(_TSTR("playqueue_overlay_genre_jump_to"));
    adapter->AddEntry(_TSTR("playqueue_overlay_add_to_playlist"));
    adapter->AddEntry(_TSTR("playqueue_overlay_add_to_start_of_queue"));
    adapter->AddEntry(_TSTR("playqueue_overlay_add_to_end_in_queue"));
    adapter->AddEntry(_TSTR("playqueue_overlay_add_as_next_in_queue"));
    adapter->SetSelectable(true);

    size_t selectedIndex = 0;
    if (!lastOperationExpired()) {
        selectedIndex = lastTrackOverlayIndex;
    }

    std::shared_ptr<ListOverlay> dialog(new ListOverlay());

    dialog->SetAdapter(adapter)
        .SetTitle(_TSTR("playqueue_overlay_track_actions_title"))
        .SetWidth(_DIMEN("playqueue_playlist_add_to_queue_overlay_width", DEFAULT_OVERLAY_WIDTH))
        .SetSelectedIndex(selectedIndex)
        .SetItemSelectedCallback(
            [track, library, &messageQueue, &playback]
            (ListOverlay* overlay, IScrollAdapterPtr adapter, size_t index) {
                if (index == ListWindow::NO_SELECTION) {
                    return;
                }

                setLastTrackOverlayIndex(index);

                auto editor = playback.Edit();
                if (index <= 2) {
                    handleJumpTo(index, messageQueue, track);
                }
                else if (index == 3) {
                    showAddTrackToPlaylistOverlay(messageQueue, library, track);
                }
                else if (index == 4) { /* start */
                    editor.Insert(track->GetId(), 0);
                }
                else if (index == 5) { /* end */
                    editor.Add(track->GetId());
                }
                else { /* next */
                    size_t position = playback.GetIndex();
                    if (position == ListWindow::NO_SELECTION) {
                        editor.Add(track->GetId());
                    }
                    else {
                        editor.Insert(track->GetId(), position + 1);
                    }
                }
            });

    cursespp::App::Overlays().Push(dialog);
}
Exemplo n.º 8
0
bool MeCtScheduler2::controller_evaluate( double time, MeFrameData& frame ) {
	vector< TrackPtr > to_remove( 0 );  // zero size because it is rarely used (don't allocate for array until needed)

	VecOfTrack::iterator end = _tracks.end();

	for( VecOfTrack::iterator i = _tracks.begin(); i != end; ++i )
	{
		TrackPtr track = *i;
		bool result = track->evaluate( time, frame );
	}

	if( !to_remove.empty() )
		remove_tracks( to_remove );
	
	return _active_when_empty || !_tracks.empty();



	///////////////////////////////////////////////////////////////////
	//// Old Scheduler Code	
	//if ( !_channels.size() ) return false; // no tracks, not active

	//MeController* ct;
	//Track* tr;
	//unsigned int i;

	///*  // Original Code for SrArray _tracks
	//// remove 'Once' controllers that have finished:
	//// note: when a controller with undetermined duration ends its tout is automatically set
	//i=0;
	//while ( i<_tracks.size() ) {
	//tr = &_tracks[i];
	//if( tr->_type==Once && tr->_tout>=0 && t>tr->_tout+tr->_ext ) { // remove this track
	//tr->_controller->stop();
	//tr->uninit();
	//_tracks.remove(i); // after this call tr pointer becomes unusable
	//} else {
	//i++;
	//}
	//}
	//*/
	//std::vector<Track>::iterator last = std::remove_if( _tracks.begin(), _tracks.end(),
	//	TrackFinalizer(t) );
	//_tracks.erase( last, _tracks.end() );


	//unsigned int trsize = _tracks.size();
	//if ( trsize==0 ) return false; // no tracks, not active anymore

	//// Mark/check controllers to be played:
	//int toplay = 0;
	//for ( i=0; i<trsize; i++ ) {
	//	tr = &_tracks[i];
	//	tr->_toplay = false; // mark as not to play
	//	if( t<tr->_tin+tr->_waitdt )
	//		continue; // not yet started
	//	if( tr->_tout>0 && t>tr->_tout+tr->_ext ) { // finished
	//		ct = tr->controller();
	//		if( ct->active() )
	//			ct->stop();
	//		continue;
	//	}

	//	tr->_toplay = true; // mark as to be played
	//	toplay++; // count number of motions to play
	//}

	//if ( toplay==0 ) return true; // no tracks were toplay at this time

	//// Evaluate the tracks and blend the buffers marked to be played:
	//float* trbuff;
	//float* buff = &buffer()[0];
	//float tloc;

	//int k;     // current active track
	//int c;     // cur channel in _channels
	//unsigned int csize; // cur channel size
	//int cf=0;  // cur channel float in _channels
	//int channels_size = _channels.size();
	//int tracks_size = _tracks.size();

	//bool easein, easeout;

	//for ( k=0; k<tracks_size; k++ )
	//{ tr = &_tracks[k];
	//if ( !tr->_toplay ) continue; // was not toplay

	//cf = 0;
	//buff = &buffer()[0];
	//ct = tr->controller();

	//double ctDuration = tr->controller()->controller_duration();
	//double tLocal = (t - tr->_tin) * tr->_speed;
	//if( tr->_toclamp ) {
	//	if( tLocal < 0 )
	//		tLocal = 0;  // first frame
	//	if( ctDuration >=0 &&
	//		tLocal > ctDuration )
	//		tLocal = ctDuration;  // final frame
	//}
	//double tEnd = tr->_tin;

	////  Anm: tout is not necessaily controller bounds..
	////       Allow controller to decide whether to evaluate.
	////       See new test in MeController::evaluate()
	////if ( tr->tout>0 && t>tr->tout ) {  // in extension period: no evaluation
	////} else {
	//if ( !ct->active() )
	//	ct->start();
	//// TODO!  Replace with temp FrameData/buffer
	//ct->evaluate ( float(tLocal), frame ); // evaluate with local time
	//if( !ct->active() && tr->_tout<0 )
	//	tr->_tout = t; // tout is now determined
	////}

	//easein = t<tr->_tin+double(tr->_waitdt+tr->_indt)? true:false; // check if in ease-in phase
	//easeout = tr->_tout>0 && t>tr->_tout+double(tr->_ext-tr->_outdt)? true:false; // check if in ease-out phase

	//for ( c=0; c<channels_size; c++ )
	//{ csize = _channels[c].size();
	//int ctChannel = ct->map()[cf];
	//if ( ctChannel>=0 ) // channel used by this track
	//{
	//	trbuff = &ct->buffer()[ctChannel];

	//	if ( easein )
	//	{ tloc =  float(t-(tr->_tin+tr->_waitdt))/tr->_indt;
	//	_channels[c].interp ( buff, buff, trbuff, spline3(tloc) );
	//	}
	//	else if ( easeout )
	//	{ tloc =  float(tr->_tout+tr->_ext-t)/tr->_outdt;
	//	_channels[c].interp ( buff, buff, trbuff, spline3(tloc) );
	//	}
	//	else // just copy values
	//	{ for ( i=0; i<csize; i++ ) buff[i]=trbuff[i];
	//	}
	//}
	//cf += csize;
	//buff  += csize;
	//}
	//}

	//return true; // returns the activation state
}
Exemplo n.º 9
0
TrackPtr
ServiceSqlRegistry::getTrack( const QStringList &rowData )
{
    //test if rowData is the correct length
    int correctLength = m_metaFactory->getTrackSqlRowCount() + m_metaFactory->getAlbumSqlRowCount() + m_metaFactory->getArtistSqlRowCount() + m_metaFactory->getGenreSqlRowCount();

    if ( rowData.size() != correctLength )
        return Meta::TrackPtr();

    int id = rowData[0].toInt();

    QMutexLocker locker( &m_trackMutex );
    if( m_trackMap.contains( id ) )
    {
        return m_trackMap.value( id );
    }
    else
    {
        int index = 0;
        TrackPtr trackPtr = m_metaFactory->createTrack( rowData.mid(index, m_metaFactory->getTrackSqlRowCount() ) );
        index += m_metaFactory->getTrackSqlRowCount();

        ServiceTrack * track = static_cast<ServiceTrack *> ( trackPtr.data() );
        AlbumPtr albumPtr;

        if ( m_albumMap.contains( track->albumId() ) )
            albumPtr = m_albumMap.value( track->albumId() );
        else
            albumPtr = getAlbum( rowData.mid( index, rowData.count() -1 ) );

        index += m_metaFactory->getAlbumSqlRowCount();

        ServiceAlbum * album = static_cast<ServiceAlbum *> ( albumPtr.data() );

        album->addTrack( trackPtr );
        track->setAlbumPtr( albumPtr );

        m_albumMap.insert( track->albumId(), albumPtr );


        ArtistPtr artistPtr;

        if ( m_artistMap.contains( track->artistId() ) )
            artistPtr = m_artistMap.value( track->artistId() );
        else
        {
            QStringList subRows = rowData.mid(index, m_metaFactory->getArtistSqlRowCount() );
            artistPtr = m_metaFactory->createArtist( subRows );
        }

        index += m_metaFactory->getArtistSqlRowCount();

        ServiceArtist * artist = static_cast<ServiceArtist *> ( artistPtr.data() );

        artist->addTrack( trackPtr );
        track->setArtist( artistPtr );

        m_artistMap.insert( track->artistId(), artistPtr );

        GenrePtr genrePtr;

        int genreId = rowData[index].toInt();

        if( m_genreMap.contains( genreId ) )
            genrePtr = m_genreMap.value( genreId );
        else
            genrePtr = m_metaFactory->createGenre( rowData.mid(index, m_metaFactory->getGenreSqlRowCount() ) );

        ServiceGenre * genre = dynamic_cast<ServiceGenre *> ( genrePtr.data() );
        Q_ASSERT( genre );

        if( genre )
            genre->addTrack( trackPtr );

        track->setGenre( genrePtr );

        m_genreMap.insert( genreId, genrePtr );

        m_trackMap.insert( id, trackPtr );
        return trackPtr;
    }
}
Exemplo n.º 10
0
void ScriptableServiceInfoParser::getInfo(TrackPtr track)
{
    DEBUG_BLOCK
    ScriptableServiceTrack * serviceTrack = dynamic_cast< ScriptableServiceTrack * >( track.data() );
    if (serviceTrack == 0) return;

    emit( info( serviceTrack->description() ) );

    if ( serviceTrack->description().isEmpty() )
    {
        showLoading( i18n( "Loading info..." ) );
        ScriptManager::instance()->ServiceScriptRequestInfo( m_serviceName, serviceTrack->level(), serviceTrack->callbackString() );
    }

}