Photos Slideshow

From WebOS Internals
Revision as of 09:56, 3 August 2009 by Hopspitfire (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


This will give you the option when viewing a fullscreen photo to start a slide show. This makes a great addition when on the touchstone.

Since we are doing this on just the fullscreen we will only be editing one file: /usr/palm/applications/com.palm.app.photos/app/controllers/fullscreen-assistant.js

First get a couple icons for playing and pausing.

I used the ones in the music player. I named mine menu-icon-play.png and menu-icon-pause.png and placed them in the '/usr/palm/applications/com.palm.app.photos/images/' folder. If you dont care what the picture is, you can change the code below to use menu-icon-send.png where ever you see play or pause. (just remember the menu, the second icon is the play and the first one is the send.


Second, add the play button to the top menu.

Find 'updateViewMenu' function, Directly after:

this.menuModel.items[0].items =
[{
    iconPath: 'images/menu-icon-send.png',
    command: 'menu-share'

Add This:

},{
    iconPath: 'images/menu-icon-play.png',
    command: 'menu-play'


Third, handle the 'menu-play' command.

Find the 'additionalHandleCommand' function. Directly after:

case 'menu-share':
    this.handleShare();
    event.stop();
    break;

Add This:

case 'menu-play':
    this.handlePlay();
    event.stop();
    break;


Finally, add two functions to control the play.

Change the timeout (15000) to how many milliseconds you want them to show for. (I added mine directly after 'handleShare' function).

handlePlay: function(event)
{
    if(this._playing)
    {
        clearTimeout(this._playing);
        delete this._playing;
        this.menuModel.items[0].items[1].iconPath = 'images/menu-icon-play.png';
    }
    else
    {
        this.menuModel.items[0].items[1].iconPath = 'images/menu-icon-pause.png';
        this.handlePlayNext();
    }
},
handlePlayNext: function()
{
        this.urlProvider.jumpTo(Math.floor(Math.random() * this.urlProvider.getTotal()));
        //10 second pause
        this._playing = this.controller.window.setTimeout(this.handlePlayNext.bind(this),10000);
},


To Do:

  • Configurable Display Time
  • Pass Parameter to start automatically
  • Configurable Option to auto start on charging


Contributions:

Adding the menu item and handling it to automatically change to next picture every X seconds by dacablegy.

I notice we have a pause icon but I don't see where we set it up to do anything. mamouton