[[BackLinksMenu]] [[TicketQuery(summary=BOOK_BACKGROUND_AUDIO_R0, format=table, col=summary|owner|status|type|component|priority|effort|importance, rows=description|analysis_owners|analysis_reviewers|analysis_score|design_owners|design_reviewers|design_score|implementation_owners|implementation_reviewers|implementation_score|test_owners|test_reviewers|test_score|)]] = 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 == [wiki:BOOK_PROPERTIES_DIALOG_R0] == 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; * 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 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 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; * Playing background audio (changes to {{{ BookView}}}): * Add the following properties: * {{{ Prop backgroundAudioResource() }}} * {{{ public Prop handler() }}} - the media handler for background audio * its value should be MediaHandler.DEFAULT_HANDLER if there is no background audio; * {{{ public Prop 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}}}. * Source code: [8093] = Implementation = * Done accoring to the design. * Source code: [8093], [8100] Merged to the trunk at [8102]. = Testing = ^(Place the testing results here.)^ = Comments = ^(Write comments for this or later revisions here.)