Changeset 158

Show
Ignore:
Timestamp:
03/08/07 22:01:09 (2 years ago)
Author:
bfitzpa2
Message:

Next button now works and the flash itself calls the next song when it's done.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • dmp/trunk/gwt-windows-1.3.3/src/DMP/client/DMPWebsite.java

    r135 r158  
    22 
    33import com.google.gwt.core.client.EntryPoint; 
     4import com.google.gwt.core.client.GWT; 
    45import com.google.gwt.user.client.ui.*; 
    5 import com.google.gwt.core.client.GWT; 
    66import com.google.gwt.user.client.rpc.*; 
    7 import com.google.gwt.user.client.Timer
     7import com.google.gwt.user.client.*
    88import java.util.Vector; 
    99import java.util.HashMap; 
     
    1919        SongTable playing = new PlayingTable(this); 
    2020        DockPanel mainPanel = new DockPanel(); 
    21         FocusPanel flashPanel = new FocusPanel(); 
     21         
     22        // the panel containing the flash movie and navigation links 
     23        DeckPanel flashPanel; 
     24         
    2225        int currentMusicDuration = 0; 
    2326        Date currentSongStart = null; 
    24          
     27        String testString = "This is a test."; 
    2528         
    2629        public void onClick(Widget w) 
     
    7376                String moduleRelativeURL = GWT.getModuleBaseURL() + "music"; 
    7477                endpoint.setServiceEntryPoint(moduleRelativeURL); 
    75  
     78                Window.setTitle("Rubicon"); 
     79                 
     80                //init javascript methods 
     81                initJavascriptAPI(this); 
     82                 
    7683                getSongsFromCollection(); 
    7784 
     
    9097                 
    9198                HorizontalPanel topPanel = new HorizontalPanel(); 
    92                 Image logo = new Image(); 
     99                 
     100                // sets the logo picture 
     101                Image logo = new Image("C:\\Documents and Settings\\Beverly Fitzpatrick\\My" +  
     102                                " Documents\\Visual Studio 2005\\Projects\\DMPGraphics\\Rubicon Logo Final.png"); 
     103                logo.setPixelSize(189, 74); //resize the logo to a resonable sizing 
    93104                topPanel.add(logo); 
     105                 
     106                // the panel containing the flash movie and html navigation links 
     107                flashPanel = new DeckPanel(); 
     108                Hyperlink nextSongLink = new Hyperlink("Next Song",false,""); 
     109                nextSongLink.addClickListener(new ClickListener(){ 
     110                        public void onClick(Widget w) 
     111                        { 
     112                                playNextSong(); 
     113                        } 
     114                }); 
     115                flashPanel.add(nextSongLink); 
     116                GWT.log(nextSongLink.getElement().toString(), null); 
     117                SimplePanel placeholder = new SimplePanel(); 
     118                flashPanel.add(placeholder); // add a blank panel as a placeholder 
     119                flashPanel.showWidget(flashPanel.getWidgetIndex(placeholder)); 
    94120                topPanel.add(flashPanel); 
     121                 
     122                // button to refresh songs from the collection 
    95123                Button refreshButton = new Button("Refresh"); 
    96124                refreshButton.addClickListener(new ClickListener(){ 
     
    143171        public void playNextSong() 
    144172        { 
     173                GWT.log("playNextSong in DMPWebsite", null); 
    145174                final boolean firstSong = (currentMusicDuration == 0); 
    146175                musicServ.getNextSong(new AsyncCallback(){ 
     
    158187                                        return; 
    159188                                } 
    160                                 HTML flash = new HTML("<object width=\"100\" height=\"100\">" + 
     189                                Widget lastFlash = flashPanel.getWidget(flashPanel.getVisibleWidget()); 
     190                                flashPanel.remove(lastFlash); //remove the last flash movie 
     191                                HTML flash = new HTML("<object width=\"50\" height=\"50\">" + 
    161192                                                "<param name=\"movie\" value=\"" + path + "\"><PARAM NAME=loop VALUE=\"false\">" +  
    162193                                                "<PARAM NAME=menu VALUE=\"true\">" + 
    163194                                                "<embed src=\"" + path +  
    164                                                 "\" width=\"100\" height=\"100\" loop=\"false\" menu=\"true\">" + 
     195                                                "\" width=\"50\" height=\"50\" loop=\"false\" menu=\"true\">" + 
    165196                                                "</embed></object>"); 
    166                                 flashPanel.setWidget(flash); 
     197                                flashPanel.add(flash); 
     198                                flashPanel.showWidget(flashPanel.getWidgetIndex(flash)); // make sure we're showing the movie 
    167199                                currentMusicDuration = Double.valueOf((String)song.get("duration")).intValue(); 
    168200                                if(firstSong) 
    169201                                { 
    170                                         Timer nextSong = new NextSongTimer(); 
    171                                         nextSong.schedule(currentMusicDuration); 
     202                                        //Timer nextSong = new NextSongTimer(); 
     203                                        //nextSong.schedule(currentMusicDuration); 
    172204                                } 
    173205                                playing.removeSong(song.get("id")); 
     
    215247                } 
    216248        } 
     249         
     250        /** 
     251         * Javascript initialization method. 
     252         */ 
     253        public native void initJavascriptAPI(DMPWebsite site)/*-{ 
     254                $wnd.nextSong = function() { site.@DMP.client.DMPWebsite::playNextSong()(); } 
     255        }-*/; 
    217256} 
  • dmp/trunk/gwt-windows-1.3.3/src/DMP/server/MusicServImpl.java

    r135 r158  
    2929        private DMPXmlRpcClient client; 
    3030        private HashMap<HashMap,File> flashFileHandles = new HashMap<HashMap,File>(); 
     31        private String graphicsPath = "C:\\Documents and Settings\\Beverly Fitzpatrick\\My" +  
     32        " Documents\\Visual Studio 2005\\Projects\\DMPGraphics\\"; 
    3133         
    3234        // testing method 
     
    4648        } 
    4749         
    48         // Need to figure out how to notify webpage that the song is now playing 
    4950        public HashMap getNextSong() 
    5051        { 
     
    5556                        song.put("duration",0); 
    5657                        return song; 
     58                } 
     59                while(!flashFileHandles.containsKey(song)) 
     60                { 
     61                        try { 
     62                                Thread.sleep(100); 
     63                        } catch (InterruptedException e) { 
     64                                // TODO Auto-generated catch block 
     65                                e.printStackTrace(); 
     66                        } 
    5767                } 
    5868                File songHandle = flashFileHandles.get(song); 
     
    209219        { 
    210220                int framesPerSecond = 12; 
    211                 FSMovie musicMov = new FSMovie(new FSBounds(0,0,930,930),new Float(framesPerSecond).floatValue()); 
     221                FSMovie musicMov = new FSMovie(new FSBounds(0,0,1000,1000),new Float(framesPerSecond).floatValue()); 
    212222                musicMov.add(new FSSetBackgroundColor(new FSColor(255,200,255))); // random color for testing 
     223                FSGetUrl nextSongAction = new FSGetUrl("javascript:nextSong()"); 
    213224 
    214225                // make the sound 
     
    232243                 
    233244                // make the next button 
    234                 String imageBasePath = "C:\\Documents and Settings\\Beverly Fitzpatrick\\My" +  
    235                         " Documents\\Visual Studio 2005\\Projects\\DMPGraphics\\"; 
    236245                FSImageConstructor imageMaker = new FSImageConstructor(); 
    237246                FSDefineObject nextHover; 
     
    239248                FSDefineObject nextPressed; 
    240249                try { 
    241                         imageMaker.setImageFromFile(imageBasePath + "Next_hover.png"); 
     250                        imageMaker.setImageFromFile(graphicsPath + "Next_hover.png"); 
    242251                        nextHover = imageMaker.defineImage(musicMov.newIdentifier()); 
    243                         imageMaker.setImageFromFile(imageBasePath + "Next_nohover.png"); 
     252                        imageMaker.setImageFromFile(graphicsPath + "Next_nohover.png"); 
    244253                        nextNoHover = imageMaker.defineImage(musicMov.newIdentifier()); 
    245                         imageMaker.setImageFromFile(imageBasePath + "Next_pressed.png"); 
     254                        imageMaker.setImageFromFile(graphicsPath + "Next_pressed.png"); 
    246255                        nextPressed = imageMaker.defineImage(musicMov.newIdentifier()); 
    247256                } catch (IOException e2) { 
     
    253262                } 
    254263                FSDefineShape3 nextNoHoverShape = imageMaker.defineEnclosingShape(musicMov.newIdentifier(), 
    255                                 nextNoHover.getIdentifier(), 0, 0, new FSSolidLine(1,new FSColor(5,5,5))); 
     264                                nextNoHover.getIdentifier(), 0, 0, new FSSolidLine(1,new FSColor(0,0,10))); 
    256265                FSDefineShape3 nextHoverShape = imageMaker.defineEnclosingShape(musicMov.newIdentifier(), 
    257                                 nextHover.getIdentifier(), 0, 0, null); 
     266                                nextHover.getIdentifier(), 0, 0, new FSSolidLine(1,new FSColor(10,0,0))); 
    258267                FSDefineShape3 nextPressedShape = imageMaker.defineEnclosingShape(musicMov.newIdentifier(), 
    259                                 nextPressed.getIdentifier(), 0, 0, null); 
     268                                nextPressed.getIdentifier(), 0, 0, new FSSolidLine(1,new FSColor(0,10,0))); 
    260269 
    261270                // make the buttons 
    262                 ArrayList<FSButton> nextButtonImages = new ArrayList<FSButton>(); 
    263                 nextButtonImages.add(new FSButton(FSButton.Up, nextNoHoverShape.getIdentifier(), 2)); 
    264                 nextButtonImages.add(new FSButton(FSButton.Over, nextHoverShape.getIdentifier(), 1)); 
    265                 nextButtonImages.add(new FSButton(FSButton.Down, nextPressedShape.getIdentifier(), 3)); 
     271                ArrayList<FSButton> nextButtonParts = new ArrayList<FSButton>(); 
     272                nextButtonParts.add(new FSButton(FSButton.Up, nextNoHoverShape.getIdentifier(), 1)); 
     273                nextButtonParts.add(new FSButton(FSButton.Over, nextHoverShape.getIdentifier(), 2)); 
     274                nextButtonParts.add(new FSButton(FSButton.Down, nextPressedShape.getIdentifier(), 3)); 
     275                nextButtonParts.add(new FSButton(FSButton.Active, nextNoHoverShape.getIdentifier(),4)); 
    266276                 
    267277                // button actions 
    268                 ArrayList nextButtonActions = new ArrayList(); 
     278                ArrayList<FSActionObject> nextButtonActions = new ArrayList<FSActionObject>(); 
     279                nextButtonActions.add(new FSGetUrl("javascript:nextSong()")); 
    269280                 
    270281                // define the button and add it to the movie 
    271282                FSDefineButton nextButton = new FSDefineButton(musicMov.newIdentifier(),  
    272                                 nextButtonImages, nextButtonActions); 
     283                                nextButtonParts, nextButtonActions); 
     284                nextButton.setButtonRecords(nextButtonParts); 
    273285                musicMov.add(nextHover); 
    274286                musicMov.add(nextNoHover); 
     
    279291                musicMov.add(nextButton); 
    280292                musicMov.add(new FSPlaceObject(nextButton.getIdentifier(), 1, 0, 0)); 
     293                // done making the button and placing it in the movie 
    281294                 
    282295                int samplesPerBlock; 
     
    298311                        if(i == numberOfBlocks - 1) // adds a stop action to the last frame of the movie 
    299312                        { 
    300                                 ArrayList<FSAction> actions = new ArrayList<FSAction>(); 
     313                                ArrayList<FSActionObject> actions = new ArrayList<FSActionObject>(); 
    301314                                actions.add(new FSAction(FSAction.Stop)); 
     315                                actions.add(nextSongAction); 
    302316                                FSDoAction action = new FSDoAction(actions); 
    303317                                musicMov.add(action);