Last modified 15 years ago
Last modified on 11/15/09 19:35:52
Analysis
(Give as much as possible of the needed information for designing and implementing the task in the following sections.)
Overview
With the timelines conception that we have now it is impossible to have an audio background which plays for the whole book no matter if the user go through the pages in the same time. With this task we must add such functionality.
Task requirements
- In the book properties window, which is evoked from the File>Book Properties, create a dropdown menu which includes all audio resources available for the current book.
- Next to it must be a checkbox which toggles whether the audio should be looped or not.
- When a new book is created the dropdown menu must not be presented because there are no audio resources in the new books.
Task result
The result of this task must be source code.
Implementation idea
- Change BookPropertiesDialog.Input to be constructed not by BookInfo, but by BookH. This will enable it to collect all audio resources in the current book and give them to the dialog which will show them in a combo box.
- See the implementation of media frame views and add such functionality in BookView.
- Make sure that a book with background audio can be persisted approproately.
Related
How to demo
- Create a book.
- Add some audio resources.
- Choose one audio file for background of the book.
- Open the book with preview mode or in reader.
Design
- Model & BookPropertiesDialog
- Add two new keys in BookR4:
- KEY_BACKGROUND_AUDIO holding a reference to the background audio resource of the book.
- its default value should be ResourceRefR4.NONE_REF;
- KEY_LOOP_BACKGROUND_AUDIO holding whether the background audio of the book should be looped.
- its default value should be true;
- KEY_BACKGROUND_AUDIO holding a reference to the background audio resource of the book.
- Add helper methods to get the new keys in BookH;
- Add the reference to the background audio resource and whether it should be looped as private fields in BookInfo;
- BookPropertiesDialog.Input should provide the dialog with all the relevant information - BookInfo and the titles and references to all audio resources.
- public BookInfo getInfo() returns the initial BookInfo for the dialog
- public List<ResourceRefR4> getAudioResRefs() returns a list containing references to all audio resources in the book in the same order as their references returned by getAudioResTitles()
- public List<String> getAudioResTitles() returns a list containing the titles of all audio resources in this book in the same order as their references returned by Input.getAudioResRefs()
- getAudioResRefs() and getAudioResTitles() should contain ResourceRef.NONE_REF and a title for it, so that the user can always turn background audio off;
- Add a combo box in BookPropertiesDialog for chosing the background audio resource among all audio resources in the book:
- add two private fields in BookPropertiesDialog.SwingDialog : JLabel bgAudioLabel and JComboBox bgAudioComboBox;
- add two methods that construct the label and combo box, respectively;
- private JLabel getBgAudioLabel()
- private JComboBox getBgAudioComboBox() - create a new combo box, add to its model all titles returned by the input, set the current background audio resource as selected and setup the preferred size;
- add the label and combo box to the jpanel in getContentPanel()
- modify the logic in the Ok button listener to respect the new setting
- Add a checkbox in BookPropertiesDialog for choosing whether background audio should be looped or not - similar to adding the combo box;
- Modify FileMenuLogic's ON_OPEN_BOOK_PROPERTIES operation to respect the new settings;
- Add two new keys in BookR4:
- Playing background audio (changes to BookView):
- Add the following properties:
- Prop<AudioResourceH> backgroundAudioResource()
- public Prop<MediaHandler> handler() - the media handler for background audio
- its value should be MediaHandler.DEFAULT_HANDLER if there is no background audio;
- public Prop<Boolean> loopBackgroundAudio() - whether the background audio for this book should be looped.
- Add a new method private AudioChunk getBgAudioChunk(TimePos time) - gets the chunk of the background audio resource that should be played at the specified moment.
- If background audio is off or the background audio is not looped and the time in millis is bigger that the duration of the audio, it should return AudioChunk.SILENCE.
- Add the following properties:
- Source code: [8093]
Implementation
Merged to the trunk at [8102].
Testing
(Place the testing results here.)
Comments
(Write comments for this or later revisions here.)