~alfonsosanchezbeato/media-hub/reimplement-shuffling

« back to all changes in this revision

Viewing changes to src/core/media/player_implementation.cpp

  • Committer: Alfonso Sanchez-Beato
  • Date: 2015-11-17 08:07:22 UTC
  • mfrom: (162.1.17 media-hub)
  • Revision ID: alfonso.sanchez-beato@canonical.com-20151117080722-jz5uecejzr1arq5e
MergeĀ lp:~phablet-team/media-hub/add_move_trackĀ (go_to)

Show diffs side-by-side

added added

removed removed

Lines of Context:
512
512
        }
513
513
    });
514
514
 
515
 
 
516
 
    d->track_list->on_go_to_track().connect([this](std::pair<const media::Track::Id, bool> p)
 
515
    d->track_list->on_go_to_track().connect([this](const media::Track::Id& id)
517
516
    {
518
517
        // This lambda needs to be mutually exclusive with the about_to_finish lambda above
519
518
        const bool locked = d->doing_go_to_track.try_lock();
522
521
        if (!locked)
523
522
            return;
524
523
 
525
 
        const media::Track::Id id = p.first;
526
 
        const bool toggle_player_state = p.second;
527
 
 
528
 
        if (toggle_player_state)
529
 
            d->engine->stop();
 
524
        // Store whether we should restore the current playing state after loading the new uri
 
525
        const bool auto_play = Parent::playback_status().get() == media::Player::playing;
530
526
 
531
527
        const Track::UriType uri = d->track_list->query_uri_for_track(id);
532
528
        if (!uri.empty())
537
533
            d->engine->open_resource_for_uri(uri, do_pipeline_reset);
538
534
        }
539
535
 
540
 
        if (toggle_player_state)
 
536
        if (auto_play)
541
537
        {
542
 
            std::cout << "Toggling player state to play in on_go_to_track" << std::endl;
 
538
            std::cout << "Restoring playing state in on_go_to_track()" << std::endl;
543
539
            d->engine->play();
544
540
        }
545
541
 
696
692
        return true;
697
693
    }
698
694
 
699
 
    const bool ret = d->engine->open_resource_for_uri(uri, false);
 
695
    static const bool do_pipeline_reset = false;
 
696
    const bool ret = d->engine->open_resource_for_uri(uri, do_pipeline_reset);
700
697
    // Don't set new track as the current track to play since we're calling open_resource_for_uri above
701
698
    static const bool make_current = false;
702
699
    d->track_list->add_track_with_uri_at(uri, media::TrackList::after_empty_track(), make_current);