Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Why do I need a QTCanvas (JCanvas) for audio?



Today I found a peculiar problem where my audio only files (.wav, or .mov
with only an audio track), would only play a few seconds of audio and then
go silent. What I discovered is that they continue to play, and reach the
end like normal but you can no longer hear it.

I then took the "PlayMovie" example right from the Apple developer website,
and striped it down to the code below.
Why is it that I need a QTCanvas in order to play an audio only file?? If I
uncomment the 3 lines containing the myQTCanvas variable, I can hear the
whole .wav file playing. If I leave them commented, it plays about 3 seconds
and goes silent.
Is this a bug?
I'm using windows 2000, JDK 1.3.1_06


Noel Murphy

/*
* QuickTime for Java SDK Sample Code

Usage subject to restrictions in SDK License Agreement
* Copyright: ) 1996-1999 Apple Computer, Inc.

*/
public class PlayMovie extends Frame implements Errors {
public static void main (String args[]) {
try {
QTSession.open();
// make a window and show it - we only have one window/one movie at a
time
PlayMovie pm = new PlayMovie("QT in Java");
pm.show();
pm.toFront();
} catch (QTException e) {
// at this point we close down QT if an exception is generated because it
means
// there was a problem with the initialization of QT>
e.printStackTrace();
QTSession.close ();
}
}

public PlayMovie (String title) {
super (title);
// myQTCanvas = new QTCanvas();

// add(myQTCanvas);
addWindowListener(new WindowAdapter () {
public void windowClosing (WindowEvent e) {
goAway();
}

public void windowClosed (WindowEvent e) {
System.exit(0);
}
});

createNewMovieFromURL("C:\\venus.wav");
}

private QTDrawable myPlayer;
private Movie m;
private QTCanvas myQTCanvas;

// This will resize the window to the size of the new movie
public void createNewMovieFromURL (String theURL) {
try {
QTFile qtFile = new QTFile(new File(theURL));
m = Movie.fromFile(OpenMovieFile.asRead(qtFile));

myPlayer = new MoviePlayer (m);

// myQTCanvas.setClient (myPlayer, true);

// this will set the size of the enclosing frame to the size of the
incoming movie
pack();

//no user control over MoviePlayer or MoviePresenter so set rate
if (true)
((Playable)myPlayer).setRate(1);

} catch (QTException err) {
err.printStackTrace();
}
}

public static void goAway () {
QTSession.close();
System.exit(0);
}
}
_______________________________________________
quicktime-java mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/quicktime-java
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.