Rockbox Technical Forums

Rockbox General => Rockbox General Discussion => Topic started by: gaugino on August 17, 2017, 08:11:13 PM

Title: Automatic playback on startup
Post by: gaugino on August 17, 2017, 08:11:13 PM
Dear Rockbox Team!

Thank you for your work on Rockbox! I use Rockbox for several years on my Sansa ClipZip, and during the last 2-3 years I have the following problem: playback starts automatically when I turn on the player. I had this problem with v. 3.13, the same thing with v. 3.14. After installing v. 3.14 (using the Rockbox Utility) I reset settings, it did not help.
I use "Previous Screen" setting in the "Start Screen" option. But even if I pause a song before turning off the player, the song begins to play automatically when I turn on the player or when I plug it to the charger. Is it normal? It would be much more convenient if there was a possibility to keep the song paused after turning on the player. I have failed to find the option which could solve the problem.
I would appreciate your help.
Title: Re: Automatic playback on startup
Post by: gaugino on August 23, 2017, 01:37:25 PM
Yesterday I checked the problem, described above, on a Clip+ player with the Rockbox and on another Clip Zip player. The Clip Zip was with the stock firmware, so I installed the last Rockbox on it. The situation is exactly the same - if one pauses the song on the WPS and then turns off the player, the song begins to play automatically after turning on the player (of course, if the "Previous Screen" option is selected in the "Start Screen" setting). So, it is not a bug of my Clip Zip, but the feature of the Rockbox.

Of course, the problem can be solved by choosing, say, the "Main Menu" option in the "Start Screen" setting. But as for me, it would be much more convenient (using the "Previous Screen" option), if the Rockbox remembered the state of the playback (play or pause) and applied it after the startup of the player (if it goes to WPS at startup).
Title: Re: Automatic playback on startup
Post by: Bilgus on August 23, 2017, 02:11:34 PM
*Previous Screen* Doesn't seem to store the Main Menu after you exit the playback screen so it goes back to now playing screen

I think this is a limitation of having the power button do double duty as *Return* and *Power Off*.

I'm not sure how you could really 'fix' it as if you make it recognize the *Main Menu* then it will always return there since the power button returns you to the *Main Menu* just prior to power off, otherwise you could just select a different menu before shutdown and start there or change the 'Start Screen' setting
Title: Re: Automatic playback on startup
Post by: gaugino on August 23, 2017, 03:43:00 PM
Bilgus,
thank you for the answer!

I did not realize that this could be the effect of the power button double duty. I just have checked that the "Previous Screen" indeed does not store the Main Menu position. I usually shut down my Clip Zip on WPS, so I did not observe this effect during several years (or simply forgot about it) :). Indeed, when I power off while residing, say, in Settings, the system first goes back to Main Menu (the Main Menu appears on the screen) and only then turns off the player. However, when I power off while on WPS, the Main Menu does not appear on the screen before turning off the player - there is still a background image of the WPS theme (I use my own custom WPS). That is why I did not even think about possible effect of the power button double duty... So, thank you for the clarification!

However, it is not necessary to store the Main Menu when you exit WPS. I mean that it would be nice to have a possibility to force the pause when the system goes to WPS on startup (of course, if the Start Screen option is not "Resume Playback"). However, I don't know whether such an option can be easily realized in Rockbox...
Title: Re: Automatic playback on startup
Post by: Bilgus on August 23, 2017, 04:25:25 PM
It wouldn't be hard to add the option but I'm not sure how likely it would be that it gets added to the mainline release.
However, if you would like to make your own patch for it I could help guide you on how to proceed
Title: Re: Automatic playback on startup
Post by: gaugino on August 23, 2017, 04:56:05 PM
Bilgus,
thank you for your help and for the suggestion!

Unfortunately, I am not sure I have enough skills to make a patch. I am rather tech savvy, so it is not difficult for me to write my own WPS, etc. However, I am not a programmer, so it will take a large amount of time just to understand how to deal with Rockbox...
If the problem can not be solved just by changing some settings or by simple editing of the configuration files, I will choose the "Main Menu" option for the Start Screen, it is the simplest (and not the worst) solution.

Once again thank you for the help!
Title: Re: Automatic playback on startup
Post by: Bilgus on August 23, 2017, 06:32:48 PM
It really wasn't hard to add the functionality here is the diff file
Code: [Select]
--- /home/ubuntu/Desktop/orig/rockbox/apps/gui/wps.c 2016-10-27 01:50:12.388048590 +0200
+++ apps/gui/wps.c 2017-08-24 04:58:50.798515757 +0200
@@ -1213,6 +1213,9 @@
     state->paused = false;
     if(audio_status() & AUDIO_STATUS_PLAY)
     {
+        if(global_settings.start_in_screen == 0 && state->id3 == NULL)
+            audio_pause(); /*If there was no current track pause playback*/
+
         state->id3 = audio_current_track();
         state->nid3 = audio_next_track();
     }

basically all this does is checks if start_in_screen == previous screen and if there wasn't a track already loaded

and below are precompiled firmware for the clip+ and clipzip based on the current HEAD of the dev builds with the functionality you asked for added
http://www.mediafire.com/?bjp1te1et1t2h <--Updated

Really this needs to be controlled by a setting before it is perfect but I'll leave that as an exercise for you

Title: Re: Automatic playback on startup
Post by: gaugino on August 23, 2017, 07:24:24 PM
Dear Bilgus,

thank you very much for the help! I very much appreciate that you spent your time to create the build especially for me!

I just installed the build on my Clip Zip (unfortunately, Clip+ is not with me, so I am unable to test the build for Clip+), reset all the settings (just in case) and choose "Previous Screen" for Start Screen. Unfortunately, the player still starts playback automatically after power up... Maybe it is a feature of the Sansa players that overrides the changes in the Rockbox that you have made?
Title: Re: Automatic playback on startup
Post by: Bilgus on August 23, 2017, 09:39:12 PM
no it's probably that the clipzip takes longer to startup than the clip+ which is what I tested it on, I'll see what I can do and update the post above; Update, Ok it should work for you now

Now lets talk about caveats, since we are no longer going on lasttime, it may not be exactly what you desired since anytime there is not a track loaded it will go into the WPS and you will have to press PLAY to get it to start but this is about as good as you're going to get without running some test code for me
Title: Re: Automatic playback on startup
Post by: gaugino on August 24, 2017, 09:36:47 AM
Dear Bilgus,

now everything works perfectly, this is exactly what I need! I will also install this build on my father's Clip Zip and, as soon as I get my old Clip+ (it is not with me now, but I will get it again in 1-2 weeks), I will install the build on the Clip+ too.

As for the caveat, it is not a problem for me to press PLAY one more time in the situation with no track loaded - the advantages of this build outweigh this small drawback (at least for me).

Once again thank you very much for your help and efforts!!! If you ever need to test a code on Clip Zip, I am ready to help you.

PS: maybe a very naive and incorrect question, but what if not to use lasttime equal to 0, but to use a condition like lasttime<1-2sec or a parameter (if exists) like runtime<1-2sec (or a time which is necessary to rockbox to load if 1-2 sec is not enough)?   
Title: Re: Automatic playback on startup
Post by: Bilgus on August 24, 2017, 03:04:23 PM
That is exactly what I was going to try but I wanted to guarantee that it would work, its hard telling how many 'ticks' (1/100) of a second its going to count to before it gets to my code, but hey if its good enough for your use why not leave it as is
Title: Re: Automatic playback on startup
Post by: gaugino on August 24, 2017, 03:28:05 PM
Dear Bilgus,

my question was just for fun :) Everything is fine now, and please don't spend your time on it (but of course, if it is interesting for you or if it can be useful for future builds, I am ready to be a tester :) ).
Title: Re: Automatic playback on startup
Post by: gaugino on August 24, 2017, 04:30:53 PM
Just to add. I think that in principle such an option in the Settings menu, if ever added to the main release, could be useful for someone. It is indeed convenient to go to the previous screen after power up (there would be no such an option if it was useless). Moreover, if this previous screen is WPS, sometimes it is convenient when the playback starts automatically (but not always). However, when you plug the player, say, to the charger; or disconnect it from the PC, the playback also starts automatically. The latter is not good, in particular, when you forget to press PAUSE just after plugging the player to a charger and two hours later find your audiobook in a completely different timestamp :) Or if your player is connected to the stereo system and the volume is high :)

If I were able to add such a feature by myself, no doubt I would do it . But now many thanks to Bilgus!
Title: Re: Automatic playback on startup
Post by: Bilgus on September 26, 2017, 02:38:55 PM
I added this functionality in a patch on gerrit
http://gerrit.rockbox.org/r/#/c/1675/

Needs testing..
Title: Re: Automatic playback on startup
Post by: gaugino on September 29, 2017, 11:00:32 PM
Hi!
I am ready to do the test. Where can I get the compiled firmware?
Title: Re: Automatic playback on startup
Post by: Bilgus on September 30, 2017, 02:50:33 AM
Here is a build for the ClipZip I didn't build the manual though, it just has...
Quote
Pause First Loaded Track:
  If enabled and a track was not previously loaded since startup
  then playback is paused pending an explicit press of the play button.

since the lang file changed you will need to copy the rockbox.sansa file and the 'langs' directory, but really its just easier to rename your old .rockbox folder and copy the whole .rockbox folder in the .zip file to your device
ClipZip
http://www.mediafire.com/file/1k963yxrffp3yso/ClipZip-NoAutoResume_9-30-17_rockbox-full.zip

Clip+
http://www.mediafire.com/file/35duq5n11u90t1b/Clip%2B_NoAutoResume_10-4-17_rockbox-full.zip

oh yeah the setting can be found in mainmenu>Settings>General Settings>Startup/Shutdown>Pause First Loaded Track
Title: Re: Automatic playback on startup
Post by: gaugino on September 30, 2017, 02:04:30 PM
Just installed the build. Playback is paused on startup, but there is no menu setting "Pause First Loaded Track" in "Startup/Shutdown"...
Title: Re: Automatic playback on startup
Post by: Bilgus on September 30, 2017, 03:12:03 PM
odd Let me check that I uploaded the right firmware

Ok I updated the link in the post above sorry, I managed compile that first one with the hard coded edit instead of the latest one on gerrit
Title: Re: Automatic playback on startup
Post by: gaugino on September 30, 2017, 05:33:16 PM
At first glance, in the new build everything is fine, the new option works as it should. Thank you!
But I will test this firmware a couple days.
Title: Re: Automatic playback on startup
Post by: gaugino on October 04, 2017, 03:58:37 AM
I haven't found any bugs or drawbacks so far. Everything works fine. Thank you!

PS: Bilgus, may I ask you to compile the firmware for Clip+ too?
Title: Re: Automatic playback on startup
Post by: Bilgus on October 04, 2017, 08:39:14 PM
I put the build for the clip+ in the prior post, Enjoy..
Title: Re: Automatic playback on startup
Post by: gaugino on October 05, 2017, 09:35:46 AM
Thank you very much!