/* * winAmp.java * * Created on 20. listopad 2006, 22:43 */ import java.awt.*; import java.applet.*; import javax.swing.*; import java.io.*; import java.net.*; /** * * @author Petr */ public class winAmp extends javax.swing.JApplet { /** Initializes the applet winAmp */ public void init() { try { java.awt.EventQueue.invokeAndWait(new Runnable() { public void run() { initComponents(); } }); } catch (Exception ex) { ex.printStackTrace(); } } public void start(){ } public void stop(){} public void destroy(){} public void nacti_klip(){ try { klip = getAudioClip(new URL("file:/"+pole[track])); System.out.println("hraji"); } catch (MalformedURLException vyjimka){ System.out.println("Doslo k chybe pri vytvareni odkazu"); } } public void zobraz_klip(){ jLabel4.setText(pole[track]); } /* public void pouze_jednou(int dopredu,int dozadu){ /*funkce ošetřuje případ, že je přehráván jeden klip druhý se načte a uživatel zmáčkne dopředu nebo dozadu tlačítko if (dopredu==1){ if(pocet_track!=track&jednou>0){ track--; System.out.println(pocet_track); System.out.println(track); System.out.println("jednou"); jednou=0; } } if (pocet_track==track&dozadu==1){ if(pocet_track==track){ if(jednou>0){ track--; jednou=0; } }} }*/ AudioClip klip; String nazev_souboru; String hraj="none"; int i=0; int track; int loop=0; int pocet_track=0; int jednou=0; int dopredu; int dozadu; String pole[]=new String[10]; //String playlist[]; /** This method is called from within the init() method to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ // private void initComponents() { jPanel1 = new javax.swing.JPanel(); jButton1 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); jButton3 = new javax.swing.JButton(); jButton4 = new javax.swing.JButton(); jRadioButton1 = new javax.swing.JRadioButton(); jRadioButton3 = new javax.swing.JRadioButton(); jPanel2 = new javax.swing.JPanel(); jFileChooser1 = new javax.swing.JFileChooser(); jScrollPane1 = new javax.swing.JScrollPane(); jTextArea1 = new javax.swing.JTextArea(); jLabel4 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); jLabel6 = new javax.swing.JLabel(); jLabel7 = new javax.swing.JLabel(); jLabel1 = new javax.swing.JLabel(); jButton5 = new javax.swing.JButton(); jPanel1.setBackground(new java.awt.Color(204, 51, 0)); jButton1.setText("PLAY"); jButton1.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jButton1MouseClicked(evt); } }); jButton2.setText("STOP"); jButton2.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jButton2MouseClicked(evt); } }); jButton3.setText("<<"); jButton3.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jButton3MouseClicked(evt); } }); jButton4.setText(">>"); jButton4.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jButton4MouseClicked(evt); } }); jRadioButton1.setBackground(new java.awt.Color(204, 51, 0)); jRadioButton1.setText("repeat"); jRadioButton1.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); jRadioButton1.setMargin(new java.awt.Insets(0, 0, 0, 0)); jRadioButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton1ActionPerformed(evt); } }); jRadioButton1.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { jRadioButton1StateChanged(evt); } }); jRadioButton3.setBackground(new java.awt.Color(204, 51, 0)); jRadioButton3.setText("shuffle"); jRadioButton3.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); jRadioButton3.setMargin(new java.awt.Insets(0, 0, 0, 0)); jPanel2.setLayout(new java.awt.BorderLayout()); jPanel2.setBackground(new java.awt.Color(255, 51, 0)); jFileChooser1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jFileChooser1ActionPerformed(evt); } }); jTextArea1.setColumns(20); jTextArea1.setRows(5); jTextArea1.setText("Jednotliv\u00e9 tracky\nbudou odd\u011bleny\nst\u0159edn\u00edky a mus\u00ed \nb\u00fdt ve form\u00e1tu\n*.au "); jScrollPane1.setViewportView(jTextArea1); jLabel4.setForeground(new java.awt.Color(51, 255, 51)); jLabel4.setText("none"); jLabel5.setText("none"); jLabel6.setText("Pr\u00e1v\u011b p\u0159ehr\u00e1van\u00fd klip:"); jLabel7.setText("Posledn\u00ed na\u010dten\u00fd klip:"); jLabel1.setFont(new java.awt.Font("Tahoma", 1, 15)); jLabel1.setText("Playlist:"); jButton5.setText("jButton5"); jButton5.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton5ActionPerformed(evt); } }); org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel1Layout.createSequentialGroup() .add(18, 18, 18) .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false) .add(jPanel1Layout.createSequentialGroup() .add(jFileChooser1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 412, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jLabel1) .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 116, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .add(238, 238, 238) .add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .add(jPanel1Layout.createSequentialGroup() .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jLabel7) .add(jLabel6)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jLabel4) .add(jLabel5))) .add(jPanel1Layout.createSequentialGroup() .add(jButton1) .add(6, 6, 6) .add(jButton2) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jButton3) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jButton4) .add(14, 14, 14) .add(jRadioButton1) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jRadioButton3) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jButton5))) .addContainerGap(68, Short.MAX_VALUE)) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel1Layout.createSequentialGroup() .add(22, 22, 22) .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel1Layout.createSequentialGroup() .add(jLabel6) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jLabel7)) .add(jPanel1Layout.createSequentialGroup() .add(jLabel4) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jLabel5))) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jButton1) .add(jButton2) .add(jButton3) .add(jButton4) .add(jRadioButton1) .add(jRadioButton3) .add(jButton5)) .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel1Layout.createSequentialGroup() .add(78, 78, 78) .add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .add(jPanel1Layout.createSequentialGroup() .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel1Layout.createSequentialGroup() .add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 30, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 327, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .add(jFileChooser1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))) .addContainerGap(22, Short.MAX_VALUE)) ); getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER); }// private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) { jFileChooser1.showOpenDialog(this); } private void jRadioButton1StateChanged(javax.swing.event.ChangeEvent evt) { } private void jRadioButton1ActionPerformed(java.awt.event.ActionEvent evt) { switch(loop) { case 0: klip.loop(); loop++; System.out.println("smycka"); break; case 1: klip.stop(); klip.play(); System.out.println("smycka neni"); loop--; break; } } private void jButton4MouseClicked(java.awt.event.MouseEvent evt) { klip.stop(); track++; //pouze_jednou(1,0); if(pole[track]==null){ track=0; } nacti_klip(); klip.play(); zobraz_klip(); } private void jButton3MouseClicked(java.awt.event.MouseEvent evt) { klip.stop(); track--; //pouze_jednou(0,1); if(track<0){ track=pocet_track-1; } nacti_klip(); System.out.println(pocet_track); klip.play(); zobraz_klip(); } private void jButton2MouseClicked(java.awt.event.MouseEvent evt) { klip.stop(); } private void jButton1MouseClicked(java.awt.event.MouseEvent evt) { nacti_klip(); klip.play(); zobraz_klip(); jednou=0; } private void jFileChooser1ActionPerformed(java.awt.event.ActionEvent evt) { if(pole[0]==null) { jTextArea1.setText(null); } File f = jFileChooser1.getSelectedFile(); nazev_souboru = f.toString(); pole[i]=nazev_souboru; jTextArea1.append(pole[i]+" ; "); jLabel5.setText(pole[i]); track=i; i++; jednou++; pocet_track++; } // Variables declaration - do not modify private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JButton jButton3; private javax.swing.JButton jButton4; private javax.swing.JButton jButton5; private javax.swing.JFileChooser jFileChooser1; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel6; private javax.swing.JLabel jLabel7; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JRadioButton jRadioButton1; private javax.swing.JRadioButton jRadioButton3; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JTextArea jTextArea1; // End of variables declaration }