Rockbox Technical Forums

Rockbox Development => Starting Development and Compiling => Topic started by: seamoon2 on October 16, 2017, 08:39:39 AM

Title: Skip to next track after deleting playing track by auto
Post by: seamoon2 on October 16, 2017, 08:39:39 AM
I have made several modification on binary code so I'm familiar compiling and editing. I want automatically skip to next track after deleting playing track  by automatically. Which file contains the delete function and what line should I add for skip to the next track. Could you help me about this?
Title: Re: Skip to next track after deleting playing track by auto
Post by: Bilgus on October 16, 2017, 12:08:06 PM
What would modifying binary code have to do with compiling and editing the code?

here is the menu where it gets called
https://github.com/Rockbox/rockbox/blob/03dd4b92be7dcd5c8ab06da3810887060e06abd5/apps/onplay.c#L1382
and the code it calls
https://github.com/Rockbox/rockbox/blob/03dd4b92be7dcd5c8ab06da3810887060e06abd5/apps/onplay.c#L687

A cursory look at the code you probably need to call a new function that takes into consideration the context of the menu call or at least the type of file so you don't have the thing skipping tracks any time you delete any file
Title: Re: Skip to next track after deleting playing track by auto
Post by: seamoon2 on October 16, 2017, 02:22:22 PM
As a file type I always use separate mp3 tracks, it's not problem for me however I don't know the skip next track command so I could add it the code below.

BTW As you can see the code below I removed confirmation step in my code and carried delete menu item to top so two press on select button it deletes the playing file however pressing next button inside a pocket with Sansa Clip Zip is very difficult that's why I want auto skip to next track after delete finishes. 


Code: [Select]
static int delete_file_dir(void)
{


    clear_display(true);
    splash(HZ/2, str(LANG_DELETING));
    splash(HZ/2, ID2P(LANG_DELETING));


    int rc = -1;

    if (selected_file_attr & ATTR_DIRECTORY) { /* true if directory */
        struct dirrecurse_params parm;
        parm.append = strlcpy(parm.path, selected_file, sizeof (parm.path));

        if (parm.append < sizeof (parm.path)) {
            cpu_boost(true);
            rc = remove_dir(&parm);
            cpu_boost(false);
        }
    } else {
        rc = remove(selected_file);
    }

    if (rc < OPRC_SUCCESS) {
        splash_failed(LANG_DELETE);
    } else if (rc == OPRC_CANCELLED) {
        splash_cancelled();
    }

    if (rc != OPRC_NOOP) {
        /* Could have failed after some but not all needed changes; reload */
        onplay_result = ONPLAY_RELOAD_DIR;
    }

    return 1;
}
.
Title: Re: Skip to next track after deleting playing track by auto
Post by: Bilgus on October 16, 2017, 03:07:28 PM
personally instead of deleting the file outright I think I'd just set a tag and skip to next track and later delete all the files with a particular tag

or perhaps auto rename it to DELETE_<filename>.<ext>

The track skip functionality is exposed in playback.c as void audio_skip(direction)
https://github.com/Rockbox/rockbox/blob/03dd4b92be7dcd5c8ab06da3810887060e06abd5/apps/playback.c#L3470

you'll need to include playback.h in onplay.c
onplay.c..
#include "playback.h"

Title: Re: Skip to next track after deleting playing track by auto
Post by: seamoon2 on October 16, 2017, 04:23:04 PM
I added bold line to onplay.c file and #include "playback.h" it worked. Many thanks Bilgus.  :)

rc = remove(selected_file);
audio_skip(1);