Click here to Skip to main content
11,805,035 members (66,009 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: Java JDK

I have code for playing audio file using* package and i can only able to play small clip files but not large files which runs through for mins. Could any one able to guide me to overcome this problem  I provided my code for reference:

public class SunAudioClip implements java.applet.AudioClip {
    private AudioData audiodata;
    private AudioDataStream audiostream;
    private ContinuousAudioDataStream continuousaudiostream;
    static int length; 

public SunAudioClip (String filename) throws {
        FileInputStream fis = new FileInputStream (filename);
        AudioStream audioStream = new AudioStream (fis);
        audiodata = audioStream.getData();
        audiostream = null;
        continuousaudiostream = null;
    public void play () {
        audiostream = new AudioDataStream (audiodata);
        AudioPlayer.player.start (audiostream);
    public void loop () {
        continuousaudiostream = new ContinuousAudioDataStream (audiodata);
        AudioPlayer.player.start (continuousaudiostream);
    public void stop () {
        if (audiostream != null)
            AudioPlayer.player.stop (audiostream);
        if (continuousaudiostream != null)
            AudioPlayer.player.stop (continuousaudiostream);
    public static void main (String args[]) throws Exception {
        SunAudioClip sac = new SunAudioClip ("D:\\venkat\\project\\Babu\\choose_mode_trans.wav"); ();
Posted 20-Nov-09 1:28am
Edited 20-Nov-09 9:46am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You are unlikely to get much help with this as the API is pretty much depricated and it is not recommended to use it. You should use the new shiny media api. First of all look at this demo.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 305
1 Sergey Alexandrovich Kryukov 268
2 CPallini 210
3 Richard Deeming 190
4 CHill60 150
0 OriginalGriff 3,255
1 Maciej Los 1,990
2 KrunalRohit 1,907
3 CPallini 1,855
4 Richard MacCutchan 1,227

Advertise | Privacy | Mobile
Web01 | 2.8.151002.1 | Last Updated 26 Nov 2009
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100