Beispiel #1
0
void drct_pl_prev (void)
{
    int playlist = playlist_get_playing ();
    if (playlist < 0)
        playlist = playlist_get_active ();

    playlist_prev_song (playlist);
}
Beispiel #2
0
void drct_play (void)
{
    int playlist = playlist_get_playing ();
    if (playlist < 0)
        playlist = playlist_get_active ();

    drct_play_playlist (playlist);
}
Beispiel #3
0
void drct_pl_next (void)
{
    int playlist = playlist_get_playing ();
    if (playlist < 0)
        playlist = playlist_get_active ();

    playlist_next_song (playlist, get_bool (NULL, "repeat"));
}
Beispiel #4
0
static void real_position(gint * playlist, gint * entry)
{
    if (*playlist == -2)
        *playlist = playlist_get_playing();
    if (*playlist == -1)
        *playlist = playlist_get_active();
    if (*entry == -1)
        *entry = playlist_get_position(*playlist);
}
Beispiel #5
0
static gboolean play_cb(void *unused)
{
    /* Only the active playlist is visible through DBUS interface, so make sure
     * to play from it, not another playlist. --jlindgren */
    if (playlist_get_playing () != playlist_get_active ())
        playlist_set_playing (playlist_get_active ());

    drct_play();
    return FALSE;
}
Beispiel #6
0
void drct_pl_prev (void)
{
    bool_t play = playback_get_playing ();

    int playlist = playlist_get_playing ();
    if (playlist < 0)
        playlist = playlist_get_active ();

    if (playlist_prev_song (playlist) && play)
    {
        playlist_set_playing (playlist);
        playback_play (0, FALSE);
    }
}
Beispiel #7
0
void drct_pl_next (void)
{
    bool_t play = playback_get_playing ();

    int playlist = playlist_get_playing ();
    if (playlist < 0)
        playlist = playlist_get_active ();

    if (playlist_next_song (playlist, get_bool (NULL, "repeat")) && play)
    {
        playlist_set_playing (playlist);
        playback_play (0, FALSE);
    }
}
Beispiel #8
0
void playback_play (int seek_time, bool_t pause)
{
    g_return_if_fail (! playing);

    int playlist = playlist_get_playing ();
    if (playlist < 0)
        return;

    int entry = playlist_get_position (playlist);
    if (entry < 0)
        return;

    failed_entries = 0;
    playback_start (playlist, entry, seek_time, pause);
}
Beispiel #9
0
void drct_play_playlist (int playlist)
{
    bool_t same_playlist = (playlist_get_playing () == playlist);

    if (! same_playlist)
        playlist_set_playing (playlist);

    if (playback_get_playing ())
    {
        if (playback_get_paused ())
            playback_pause ();
        else if (same_playlist)
            playback_seek (0);
    }
    else
    {
        if (playlist_get_position (playlist) < 0)
            playlist_next_song (playlist, TRUE);

        playback_play (0, FALSE);
    }
}
Beispiel #10
0
void drct_pl_delete_selected (int list)
{
    int pos = playlist_get_position (list);

    if (get_bool (NULL, "advance_on_delete")
     && ! get_bool (NULL, "no_playlist_advance")
     && playback_get_playing () && list == playlist_get_playing ()
     && pos >= 0 && playlist_entry_get_selected (list, pos))
    {
        playlist_entry_set_selected (list, pos, FALSE);
        playlist_delete_selected (list);
        pos = playlist_get_position (list); /* it may have moved */

        if (playlist_next_song (list, get_bool (NULL, "repeat"))
         && playlist_get_position (list) != pos)
            playback_play (0, FALSE);

        playlist_entry_delete (list, pos, 1);
    }
    else
        playlist_delete_selected (list);
}
Beispiel #11
0
gboolean mpris_emit_track_change(MprisPlayer * obj)
{
    gint playlist, entry;
    GHashTable *metadata;

    playlist = playlist_get_playing();
    entry = playlist_get_position(playlist);
    gchar * filename = playlist_entry_get_filename (playlist, entry);
    Tuple * tuple = playlist_entry_get_tuple (playlist, entry, FALSE);

    if (filename && tuple)
    {
        metadata = make_mpris_metadata (filename, tuple);
        g_signal_emit (obj, signals[TRACK_CHANGE_SIG], 0, metadata);
        g_hash_table_destroy (metadata);
    }

    g_free (filename);
    if (tuple)
        tuple_free (tuple);

    return (filename && tuple);
}
Beispiel #12
0
static bool_t end_cb (void * unused)
{
    g_return_val_if_fail (playing, FALSE);

    hook_call ("playback end", NULL);

    if (playback_error)
        failed_entries ++;
    else
        failed_entries = 0;

    playback_cleanup ();

    int playlist = playlist_get_playing ();
    bool_t play;

    if (get_bool (NULL, "no_playlist_advance"))
        play = get_bool (NULL, "repeat") && ! failed_entries;
    else if (! (play = playlist_next_song (playlist, get_bool (NULL, "repeat"))))
        playlist_set_position (playlist, -1);
    else if (failed_entries >= 10)
        play = FALSE;

    if (get_bool (NULL, "stop_after_current_song"))
        play = FALSE;

    if (play)
        playback_start (playlist, playlist_get_position (playlist), 0, FALSE);
    else
    {
        complete_stop ();
        hook_call ("playlist end reached", NULL);
    }

    return FALSE;
}