Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java GUI 设计 » SWT  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 求教关于声音播放的问题?
wzzxsb





发贴: 2
积分: 0
于 2007-06-03 21:42 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
import java.applet.*;
import java.awt.*;
public class sound extends Applet {
int i=0;
AudioClip a;
public void init(){
   a=getAudioClip(getDocumentBase(),"midiA.wav");
   }
public boolean mouseDown(Event e,int x,int y){
   if(i==0){
     i=1;
     a.play();
        }
   else{
     i=0;
     a.stop();
        }
   return true;
}
}

我是初学者,不知道为什么这个程序声音播放不出来,请高手指点下.不胜感谢!!



作者 Re:求教关于声音播放的问题? [Re:wzzxsb]
五分之五





发贴: 4
积分: 0
于 2007-06-09 12:21 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
你的音频文件有放在build文件夹里么?不能播放报的什么错?


作者 Re:求教关于声音播放的问题? [Re:wzzxsb]
wzzxsb





发贴: 2
积分: 0
于 2007-06-09 19:03 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我的音频文件和类文件都放在一个文件夹了.也没播报什么错误.


作者 Re:求教关于声音播放的问题? [Re:wzzxsb]
JiafanZhou



版主


发贴: 736
积分: 61
于 2007-06-12 18:32 user profilesend a private message to usersend email to JiafanZhousearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
Before I give you the solution, ask yourself some questions first:
*What does this piece code mean?
*Applet or application?
*How do you play the music in your code?
*What does mouse down mean?


/*
* @(#)MySound.java 1.0 07/06/12
*
* You can modify the template of this file in the
* directory ..\JCreator\Templates\Template_2\Project_Name.java
*
* You can also create your own project template by making a new
* folder in the directory ..\JCreator\Template\. Use the other
* templates as examples.
*
*/

import java.awt.*;
import java.applet.*;

public class MySound extends Applet {
  int i=0;
  AudioClip a;
  public void init() {
    a=getAudioClip(getDocumentBase(),"midiA.wav");
  }

  public void paint(Graphics g) {
    g.drawString("Welcome to Java!!", 50, 60 );
  }
  
  public boolean mouseDown(Event e,int x,int y){
   if(i==0){
   i=1;
   a.play();
   }
   else{
   i=0;
   a.stop();
   }
   return true;
  }
}




When I was a kid I used to pray every night for a new bike. Then I realized that The Lord doesn't work that way, so I stole one and asked him to forgive me.

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923