void CGUIWindowMusicPlaylistEditor::AppendToPlaylist(CFileItemList &newItems)
{
  OnRetrieveMusicInfo(newItems);
  FormatItemLabels(newItems, LABEL_MASKS(CSettings::Get().GetString("musicfiles.trackformat"), CSettings::Get().GetString("musicfiles.trackformatright"), "%L", ""));
  m_playlist->Append(newItems);
  UpdatePlaylist();
}
void CGUIWindowMusicPlaylistEditor::AppendToPlaylist(CFileItemList &newItems)
{
  OnRetrieveMusicInfo(newItems);
  FormatItemLabels(newItems, LABEL_MASKS(CServiceBroker::GetSettings().GetString(CSettings::SETTING_MUSICFILES_TRACKFORMAT), "%D", "%L", ""));
  m_playlist->Append(newItems);
  UpdatePlaylist();
}
示例#3
0
void Playlist::run()
{

    while(!quit)
    {
        qDebug() << "start from worker thread " << thread()->currentThreadId() ;
        sleep(1);
        boost::asio::io_service io_service;
        HttpClient c(io_service, "mts.local", "/playlist");
        io_service.run();

        std::string t = c.getResponse();
        //std::cout << t << "\n";
        std::istringstream is(t);
        Parser *p = new Parser();
        PlayStructList playlist = p->ReadPlaylist( is);
        //is.clear();
        //mutex.lock();
        emit UpdatePlaylist(playlist);
        //mutex.unlock();

        qDebug() << "end from worker thread " << thread()->currentThreadId() ;

    }

}
void CGUIWindowMusicPlaylistEditor::OnDeletePlaylistItem(int item)
{
  if (item < 0) return;
  m_playlist->Remove(item);
  UpdatePlaylist();
  // select the next item
  CGUIMessage msg(GUI_MSG_ITEM_SELECT, GetID(), CONTROL_PLAYLIST, item);
  OnMessage(msg);
}
void CGUIWindowMusicPlaylistEditor::OnMovePlaylistItem(int item, int direction)
{
  if (item < 0) return;
  if (item + direction >= m_playlist->Size() || item + direction < 0)
    return;
  m_playlist->Swap(item, item + direction);
  UpdatePlaylist();
  CGUIMessage msg(GUI_MSG_ITEM_SELECT, GetID(), CONTROL_PLAYLIST, item + direction);
  OnMessage(msg);
}
bool CGUIWindowMusicPlaylistEditor::Update(const std::string &strDirectory, bool updateFilterPath /* = true */)
{
  if (m_thumbLoader.IsLoading())
    m_thumbLoader.StopThread();

  if (!CGUIMediaWindow::Update(strDirectory, updateFilterPath))
    return false;

  m_vecItems->SetContent("files");
  m_thumbLoader.Load(*m_vecItems);

  // update our playlist control
  UpdatePlaylist();
  return true;
}
示例#7
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    //init

    ui->setupUi(this);
    InitPlaylist();

    search_model = new QStandardItemModel();


    search_model->setHorizontalHeaderLabels(
        QStringList() << QApplication::translate("nestedlayouts", "Song")
                      << QApplication::translate("nestedlayouts", "Url "));


    qDebug() << "hello from GUI thread " << QThread::currentThread();
    //connect button
    QObject::connect(ui->searchButton, SIGNAL(clicked()), this , SLOT(SearchSongHandler()));
    QObject::connect(ui->addButton, SIGNAL(clicked()), this , SLOT(AddSongHandler()));

    ui->searchView->setSelectionMode(QAbstractItemView::ExtendedSelection);
    qRegisterMetaType<PlayStructList>("PlayStructList");
    connect(&playlist_thread, SIGNAL(UpdatePlaylist(PlayStructList)), this,
                                SLOT(ShowPlaylist(PlayStructList)));


    stream = new Stream;


    InitStream();
    //connect button stop stream
    QObject::connect(ui->pauseButton, SIGNAL(clicked()), this , SLOT(StartStopStream()));
    //ui->songNameLabel->setText("test");
    ui->lcdTime->display("00:00");
    connect(stream->mediaObject, SIGNAL(tick(qint64)), this, SLOT(tick(qint64)));
    //connect(stream, SIGNAL(UpdateTimer(QTime displayTime)), this, SLOT(ShowTimer(QTime displayTime)));

}
示例#8
0
/*****************************************************************************
 * PlayListWindow::PlayListWindow
 *****************************************************************************/
PlayListWindow::PlayListWindow( BRect frame, const char* name,
                                InterfaceWindow* mainWindow,
                                intf_thread_t *p_interface )
    :   BWindow( frame, name, B_FLOATING_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
                 B_WILL_ACCEPT_FIRST_CLICK | B_ASYNCHRONOUS_CONTROLS ),
        fMainWindow( mainWindow )
{
    char psz_tmp[1024];
#define ADD_ELLIPSIS( a ) \
    memset( psz_tmp, 0, 1024 ); \
    snprintf( psz_tmp, 1024, "%s%s", a, B_UTF8_ELLIPSIS );

    p_intf = p_interface;
 
    SetName( _("playlist") );

    // set up the main menu bar
    fMenuBar = new BMenuBar( BRect(0.0, 0.0, frame.Width(), 15.0), "main menu",
                             B_FOLLOW_NONE, B_ITEMS_IN_ROW, false );

    AddChild( fMenuBar );

    // Add the File menu
    BMenu *fileMenu = new BMenu( _("File") );
    fMenuBar->AddItem( fileMenu );
    ADD_ELLIPSIS( _("Open File") );
    BMenuItem* item = new BMenuItem( psz_tmp, new BMessage( OPEN_FILE ), 'O' );
    item->SetTarget( fMainWindow );
    fileMenu->AddItem( item );

    CDMenu* cd_menu = new CDMenu( _("Open Disc") );
    fileMenu->AddItem( cd_menu );

    fileMenu->AddSeparatorItem();
    item = new BMenuItem( _("Close"),
                          new BMessage( B_QUIT_REQUESTED ), 'W' );
    fileMenu->AddItem( item );

    // Add the Edit menu
    BMenu *editMenu = new BMenu( _("Edit") );
    fMenuBar->AddItem( editMenu );
    fSelectAllMI = new BMenuItem( _("Select All"),
                                  new BMessage( MSG_SELECT_ALL ), 'A' );
    editMenu->AddItem( fSelectAllMI );
    fSelectNoneMI = new BMenuItem( _("Select None"),
                                   new BMessage( MSG_SELECT_NONE ), 'A', B_SHIFT_KEY );
    editMenu->AddItem( fSelectNoneMI );

    editMenu->AddSeparatorItem();
    fSortReverseMI = new BMenuItem( _("Sort Reverse"),
                                 new BMessage( MSG_SORT_REVERSE ), 'F' );
    editMenu->AddItem( fSortReverseMI );
    fSortNameMI = new BMenuItem( _("Sort by Name"),
                                 new BMessage( MSG_SORT_NAME ), 'N' );
fSortNameMI->SetEnabled( false );
    editMenu->AddItem( fSortNameMI );
    fSortPathMI = new BMenuItem( _("Sort by Path"),
                                 new BMessage( MSG_SORT_PATH ), 'P' );
fSortPathMI->SetEnabled( false );
    editMenu->AddItem( fSortPathMI );
    fRandomizeMI = new BMenuItem( _("Randomize"),
                                  new BMessage( MSG_RANDOMIZE ), 'R' );
fRandomizeMI->SetEnabled( false );
    editMenu->AddItem( fRandomizeMI );
    editMenu->AddSeparatorItem();
    fRemoveMI = new BMenuItem( _("Remove"),
                          new BMessage( MSG_REMOVE ) );
    editMenu->AddItem( fRemoveMI );
    fRemoveAllMI = new BMenuItem( _("Remove All"),
                                  new BMessage( MSG_REMOVE_ALL ) );
    editMenu->AddItem( fRemoveAllMI );

    // Add View menu
    fViewMenu = new BMenu( _("View") );
    fMenuBar->AddItem( fViewMenu );

    fViewMenu->SetRadioMode( true );
    BMessage* message = new BMessage( MSG_SET_DISPLAY );
    message->AddInt32( "mode", DISPLAY_PATH );
    item = new BMenuItem( _("Path"), message );
    item->SetMarked( true );
    fViewMenu->AddItem( item );

    message = new BMessage( MSG_SET_DISPLAY );
    message->AddInt32( "mode", DISPLAY_NAME );
    item = new BMenuItem( _("Name"), message );
    fViewMenu->AddItem( item );

    // make menu bar resize to correct height
    float menuWidth, menuHeight;
    fMenuBar->GetPreferredSize( &menuWidth, &menuHeight );
    // don't change next line! it's a workarround!
    fMenuBar->ResizeTo( frame.Width(), menuHeight );

    frame = Bounds();
    frame.top += fMenuBar->Bounds().IntegerHeight() + 1;
    frame.right -= B_V_SCROLL_BAR_WIDTH;

    fListView = new PlaylistView( p_intf, frame, fMainWindow,
                                  new BMessage( MSG_SELECTION_CHANGED ) );
    fBackgroundView = new BScrollView( "playlist scrollview",
                                       fListView, B_FOLLOW_ALL_SIDES,
                                       0, false, true,
                                       B_NO_BORDER );

    AddChild( fBackgroundView );

    // be up to date
    UpdatePlaylist();
    FrameResized( Bounds().Width(), Bounds().Height() );
    SetSizeLimits( menuWidth * 1.5, menuWidth * 8.0,
                   menuHeight * 5.0, menuHeight * 50.0 );

    UpdatePlaylist( true );
    // start window thread in hidden state
    Hide();
    Show();
}
示例#9
0
/*****************************************************************************
 * InterfaceWindow::MessageReceived
 *****************************************************************************/
void InterfaceWindow::MessageReceived( BMessage * p_message )
{
    switch( p_message->what )
    {
        case B_ABOUT_REQUESTED:
        {
            BAlert * alert;

            alert = new BAlert( "VLC media player" VERSION,
                                "VLC media player" VERSION " (BeOS interface)\n\n"
                                "The VideoLAN team <*****@*****.**>\n"
                                "http://www.videolan.org/", _("OK") );
            alert->Go();
            break;
        }
        case TOGGLE_ON_TOP:
            break;

        case OPEN_FILE:
            _ShowFilePanel( B_REFS_RECEIVED, _("VLC media player: Open Media Files") );
            break;

        case LOAD_SUBFILE:
            _ShowFilePanel( SUBFILE_RECEIVED, _("VLC media player: Open Subtitle File") );
            break;
#if 0
        case OPEN_PLAYLIST:
            if (fPlaylistWindow->Lock())
            {
                if (fPlaylistWindow->IsHidden())
                    fPlaylistWindow->Show();
                else
                    fPlaylistWindow->Activate();
                fPlaylistWindow->Unlock();
            }
            break;
#endif
        case OPEN_DVD:
            {
                const char * psz_device;
                if( p_playlist &&
                    p_message->FindString( "device", &psz_device ) == B_OK )
                {
                    char psz_uri[1024];
                    memset( psz_uri, 0, 1024 );
                    snprintf( psz_uri, 1024, "dvdnav:%s", psz_device );
                    playlist_Add( p_playlist, psz_uri, psz_device,
                        PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END, true );
                }
                UpdatePlaylist();
            }
            break;

        case SUBFILE_RECEIVED:
        {
            entry_ref ref;
            if( p_message->FindRef( "refs", 0, &ref ) == B_OK )
            {
                BPath path( &ref );
                if ( path.InitCheck() == B_OK )
                    config_PutPsz( p_intf, "sub-file", path.Path() );
            }
            break;
        }

        case STOP_PLAYBACK:
            if( p_playlist )
            {
                playlist_Stop( p_playlist );
            }
            p_mediaControl->SetStatus(-1, INPUT_RATE_DEFAULT);
            break;

        case START_PLAYBACK:
        case PAUSE_PLAYBACK:
        {
            vlc_value_t val;
            val.i_int = PLAYING_S;
            if( p_input )
            {
                var_Get( p_input, "state", &val );
            }
            if( p_input && val.i_int != PAUSE_S )
            {
                val.i_int = PAUSE_S;
                var_Set( p_input, "state", val );
            }
            else
            {
                playlist_Play( p_playlist );
            }
            break;
        }
        case HEIGHTH_PLAY:
            if( p_input )
            {
                var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT * 8 );
            }
            break;

        case QUARTER_PLAY:
            if( p_input )
            {
                var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT * 4 );
            }
            break;

        case HALF_PLAY:
            if( p_input )
            {
                var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT * 2 );
            }
            break;

        case NORMAL_PLAY:
            if( p_input )
            {
                var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT );
            }
            break;

        case TWICE_PLAY:
            if( p_input )
            {
                var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT / 2 );
            }
            break;

        case FOUR_PLAY:
            if( p_input )
            {
                var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT / 4 );
            }
            break;

        case HEIGHT_PLAY:
            if( p_input )
            {
                var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT / 8 );
            }
            break;

        case SEEK_PLAYBACK:
            /* handled by semaphores */
            break;

        case VOLUME_CHG:
            aout_VolumeSet( p_intf, p_mediaControl->GetVolume() );
            break;

        case VOLUME_MUTE:
            aout_ToggleMute( p_intf, NULL );
            break;

        case SELECT_CHANNEL:
        {
            int32 channel;
            if( p_input )
            {
                if( p_message->FindInt32( "audio-es", &channel ) == B_OK )
                {
                    var_SetInteger( p_input, "audio-es", channel );
                }
                else if( p_message->FindInt32( "spu-es", &channel ) == B_OK )
                {
                    var_SetInteger( p_input, "spu-es", channel );
                }
            }
            break;
        }

        case PREV_TITLE:
            if( p_input )
            {
                var_TriggerCallback( p_input, "prev-title" );
            }
            break;

        case NEXT_TITLE:
            if( p_input )
            {
                var_TriggerCallback( p_input, "next-title" );
            }
            break;

        case TOGGLE_TITLE:
        {
            int32 index;
            if( p_input &&
                p_message->FindInt32( "index", &index ) == B_OK )
            {
                var_SetInteger( p_input, "title", index );
            }
            break;
        }

        case PREV_CHAPTER:
            if( p_input )
            {
                var_TriggerCallback( p_input, "prev-chapter" );
            }
            break;

        case NEXT_CHAPTER:
            if( p_input )
            {
                var_TriggerCallback( p_input, "next-chapter" );
            }
            break;

        case TOGGLE_CHAPTER:
        {
            int32 index;
            if( p_input &&
                p_message->FindInt32( "index", &index ) == B_OK )
            {
                var_SetInteger( p_input, "chapter", index );
            }
            break;
        }

        case PREV_FILE:
            if( p_playlist )
            {
                playlist_Prev( p_playlist );
            }
            break;

        case NEXT_FILE:
            if( p_playlist )
            {
                playlist_Next( p_playlist );
            }
            break;

        case NAVIGATE_PREV:
            if( p_input )
            {
                vlc_value_t val;

                /* First try to go to previous chapter */
                if( !var_Get( p_input, "chapter", &val ) )
                {
                    if( val.i_int > 1 )
                    {
                        var_TriggerCallback( p_input, "prev-chapter" );
                        break;
                    }
                }

                /* Try to go to previous title */
                if( !var_Get( p_input, "title", &val ) )
                {
                    if( val.i_int > 1 )
                    {
                        var_TriggerCallback( p_input, "prev-title" );
                        break;
                    }
                }

                /* Try to go to previous file */
                if( p_playlist )
                {
                    playlist_Prev( p_playlist );
                }
            }
            break;

        case NAVIGATE_NEXT:
            if( p_input )
            {
                /* First try to go to next chapter */
                if( !var_Get( p_input, "chapter", &val ) )
                {
                    int i_chapter_count = var_CountChoices( p_input, "chapter" );
                    if( i_chapter_count > val.i_int )
                    {
                        var_TriggerCallback( p_input, "next-chapter" );
                        break;
                    }
                }

                /* Try to go to next title */
                if( !var_Get( p_input, "title", &val ) )
                {
                    int i_title_count = var_CountChoices( p_input, "title" );
                    if( i_title_count > val.i_int )
                    {
                        var_TriggerCallback( p_input, "next-title" );
                        break;
                    }
                }

                /* Try to go to next file */
                if( p_playlist )
                {
                    playlist_Next( p_playlist );
                }
            }
            break;

        // drag'n'drop and system messages
        case MSG_SOUNDPLAY:
            // convert soundplay drag'n'drop message (containing paths)
            // to normal message (containing refs)
            {
                const char* path;
                for ( int32 i = 0; p_message->FindString( "path", i, &path ) == B_OK; i++ )
                {
                    entry_ref ref;
                    if ( get_ref_for_path( path, &ref ) == B_OK )
                        p_message->AddRef( "refs", &ref );
                }
            }
            // fall through
        case B_REFS_RECEIVED:
        case B_SIMPLE_DATA:
        {
            /* file(s) opened by the File menu -> append to the playlist;
               file(s) opened by drag & drop -> replace playlist;
               file(s) opened by 'shift' + drag & drop -> append */

            int32 count;
            type_code dummy;
            if( p_message->GetInfo( "refs", &dummy, &count ) != B_OK ||
                count < 1 )
            {
                break;
            }

            bool b_remove = ( p_message->WasDropped() &&
                                    !( modifiers() & B_SHIFT_KEY ) );

            if( b_remove && p_playlist )
            {
                playlist_Clear( p_playlist, true );
            }

            entry_ref ref;
            for( int i = 0; p_message->FindRef( "refs", i, &ref ) == B_OK; i++ )
            {
                BPath path( &ref );

                /* TODO: find out if this is a DVD icon */

                if( p_playlist )
                {
                    playlist_Add( p_playlist, path.Path(), NULL,
                       PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END, true );
                }
            }

            UpdatePlaylist();
            break;
        }

        case OPEN_PREFERENCES:
        {
            if( fPreferencesWindow->Lock() )
            {
                if (fPreferencesWindow->IsHidden())
                    fPreferencesWindow->Show();
                else
                    fPreferencesWindow->Activate();
                fPreferencesWindow->Unlock();
            }
            break;
        }

        case OPEN_MESSAGES:
        {
            if( fMessagesWindow->Lock() )
            {
                if (fMessagesWindow->IsHidden())
                    fMessagesWindow->Show();
                else
                    fMessagesWindow->Activate();
                fMessagesWindow->Unlock();
            }
            break;
        }
        case MSG_UPDATE:
            UpdateInterface();
            break;
        default:
            BWindow::MessageReceived( p_message );
            break;
    }
}