1   /*
2    * Created on Aug 19, 2007
3    * 
4    * Copyright 2005 CafeSip.org 
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License"); 
7    * you may not use this file except in compliance with the License. 
8    * You may obtain a copy of the License at 
9    *
10   *	http://www.apache.org/licenses/LICENSE-2.0 
11   *
12   * Unless required by applicable law or agreed to in writing, software 
13   * distributed under the License is distributed on an "AS IS" BASIS, 
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
15   * See the License for the specific language governing permissions and 
16   * limitations under the License.
17   *
18   */
19  package org.cafesip.gwtcomp.examples.client;
20  
21  import org.cafesip.gwtcomp.client.ui.Audio;
22  import org.cafesip.gwtcomp.client.ui.TitleBar;
23  
24  import com.google.gwt.event.dom.client.ClickEvent;
25  import com.google.gwt.event.dom.client.ClickHandler;
26  import com.google.gwt.user.client.ui.FlowPanel;
27  import com.google.gwt.user.client.ui.HasHorizontalAlignment;
28  import com.google.gwt.user.client.ui.HasVerticalAlignment;
29  import com.google.gwt.user.client.ui.HorizontalPanel;
30  import com.google.gwt.user.client.ui.Image;
31  
32  /**
33   * @author Amit Chatterjee
34   *
35   */
36  public class AudioSample extends FlowPanel
37  {
38      public AudioSample()
39      {
40          super();
41          setWidth("100%");
42          
43          init();
44      }
45      
46      protected void init()
47      {
48          TitleBar titleBar = new TitleBar("Audio Widgets", null, 1);
49          add(titleBar);
50          titleBar.setWidth("100%");
51  
52          HorizontalPanel audioButtonPanel = new HorizontalPanel();
53          add(audioButtonPanel);
54          audioButtonPanel.setSpacing(20);
55          audioButtonPanel
56                  .setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
57          audioButtonPanel
58                  .setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
59          audioButtonPanel.setSize("100%", "100%");
60  
61          Image playError = new Image();
62          audioButtonPanel.add(playError);
63          playError.setUrl("gwtcomp-icons/player_play.png");
64          playError.setTitle("Play Error Audio");
65          
66          playError.addClickHandler(new ClickHandler() {
67  
68              public void onClick(ClickEvent event)
69              {
70                  Audio.getInstance().playError();               
71              }});
72  
73          final Image playWarning = new Image();
74          audioButtonPanel.add(playWarning);
75          playWarning.setUrl("gwtcomp-icons/player_play.png");
76          playWarning.setTitle("Play Warning Audio");
77          
78          playWarning.addClickHandler(new ClickHandler() {
79  
80              public void onClick(ClickEvent event)
81              {
82                  Audio.getInstance().playWarning();               
83              }});
84      }
85  
86  }