Mailing Lists: Apple Mailing Lists

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

Re: Help - Processor Usage Rockets and playback flickers???



Hi Steven
We need to know :
- What platform are you running this on
- jre version
- qt version

thanks
anant

on 12/4/01 8:28 AM, STEVEN JOHNSTON at email@hidden wrote:

> Hi
>
> I've written a java app which plays a movie (from a
> file) full screen. When the movie finishes
> TimeBaseExtremesCallBack gets called (end of movie)
> and the program plays a different movie.
>
> To load the new movie I call the setMovie() method on
> the Movie Controller.
>
> This works fine - sort of, but after playing 10-15
> movies the processor usage rockets to 100% and the
> movie flickers terribly.
>
> I'm woried that I'm not releasing the previous movies
> correctly but can't find any information in the api on
> how to do this.
>
> Here is my code (sorry its not tidy but I'm working on
> a quick turnaround demo).
>
> Any help would be greatly appreciated.
>
>
> Steve Johnston
>
>
> Code
> ====
>
> package tutorial;
>
> import java.awt.*;
> import java.awt.event.*;
>
> import quicktime.*;
> import quicktime.io.*;
> import quicktime.app.display.*
> import quicktime.std.*;
> import quicktime.std.movies.*;
> import quicktime.qd.*
> import quicktime.std.movies.media.DataRef;
> import quicktime.std.StdQTException;
> import quicktime.app.display.FullScreenWindow;
> import quicktime.app.players.QTPlayer;
> import quicktime.util.StringHandle;
>
>
> public class Play extends Frame
> {
>
> public static void main (String[] args)
> {
>
> try
> {
> QTSession.open();
> Play pm = new Play();
>
> }
> catch (QTRuntimeException qre)
> {
> System.out.println("Runtime Exception: " +
> qre.getMessage());
>
> }
> catch (QTException qte)
> {
> System.out.println("Play.main(): " +
> qte.getMessage());
>
> if (Vars.DEBUG)
> qte.printStackTrace();
> }
> }
>
> public Movie getMovieFromLocation(String filename)
> throws QTRuntimeException
> {
> if (Vars.DEBUG)
> System.out.println("Entered
> Play.getMovieFromLocation() - " + filename);
>
> try
> {
> DataRef urlMovie = new DataRef(filename);
> return Movie.fromDataRef
> (urlMovie,StdQTConstants4.newMovieAsyncOK);
> }
> catch (QTException e)
> {
> System.out.println("Play.getMovieFromLocation(): "
> + e.getMessage());
>
> if (Vars.DEBUG)
> e.printStackTrace();
> }
>
> return null;
>
> }
>
> public Play() throws QTRuntimeException
> {
> super ("Play");
>
> if (Vars.DEBUG)
> System.out.println("Entered Play()");
>
> gdb = new GeoDatabase();
>
> try
> {
> // Get current Default Screen Size
> Toolkit tk = Toolkit.getDefaultToolkit();
> dimension = tk.getScreenSize();
>
> if (Vars.DEBUG)
> System.out.println("Maximum Screen Size: Width: "
> + dimension.width + " Height: " + dimension.height);
>
> // Create Full Screen Window for Movies
> w = new FullScreenWindow(new FullScreen(), this);
> w.setBackground (Color.black);
>
>
> if (Vars.DEBUG)
> {
> System.out.println("Full Screen Windows
> Created.");
> System.out.println("Getting Canvas...");
> }
>
> // Set up QTPLayer, Movie Controller and Movie
> mc = new MovieController
> (getMovieFromLocation(getNextMovieName()));
> mc.setKeysEnabled (true);
> qtp = new QTPlayer (mc);
> qtp.setDisplayBounds(new QDRect(dimension.width,
> dimension.height));
>
> // Hide Controller
> mc.setVisible(false);
>
> // setup Canvas
> myQTCanvas = new
> QTCanvas(QTCanvas.kPerformanceResize, 0.5F, 0.5F);
>
> // Add player to canvas, and then canvas to full
> screen
> myQTCanvas.setClient(qtp, true);
> w.add(myQTCanvas);
>
> w.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
>
> // Check if only film segment required
> mc.getMovie().setPreviewMode(false);
> mc.getMovie().start();
>
> theMoviesTimeBase = mc.getMovie().getTimeBase();
> theMoviesExtremeCallback = new
> TimeBaseExtremesCallBack(theMoviesTimeBase,
> StdQTConstants.triggerAtStop ); // this callback is
> triggered when the movie stops
> theMoviesExtremeCallback.callMeWhen ();
>
> if (Vars.DEBUG)
> System.out.println("Showing Window...");
>
> HideFSWindow hw = new HideFSWindow (w, myQTCanvas);
> w.addMouseListener (hw);
> myQTCanvas.addMouseListener (hw);
>
> w.show();
> w.toFront();
> }
> catch (QTException err)
> {
> System.out.println("Play.Play(): " +
> err.getMessage());
>
> if (Vars.DEBUG)
> err.printStackTrace();
> }
> catch (Exception e){}
>
> System.out.println("Play : Completed");
> }
>
> public String getNextMovieName() throws
> QTRuntimeException
> {
> gm = new GeoMovie(movies[movieCounter++]);
> if (movieCounter == movies.length)
> movieCounter=0;
>
> return gm.getMovieURL();
> }
>
> // Member Variables
> Movie currentMovie;
> MovieController mc;
> QTPlayer qtp;
> QTDrawable qtd;
> TimeBase theMoviesTimeBase;
> TimeBaseExtremesCallBack theMoviesExtremeCallback;
> FullScreenWindow w;
> Dimension dimension; // Full Screen Size
> QTCanvas myQTCanvas; // Current Canvas
> int movieCounter = 0;
> MovieCanvas movCan = new MovieCanvas();
> String[] movies =
> {"file://c:\\film\\advert.mpeg","file://c:\\film\\UBS_TOKYO_1hbr.mpg","file://
> c:\\avi\\whacking.mpeg","file://c:\\film\\advert.mpeg","file://c:\\avi\\houset
> our2.mov"};//,};
>
>
>
> class TimeBaseExtremesCallBack extends
> quicktime.std.clocks.ExtremesCallBack {
>
>
> public TimeBaseExtremesCallBack(TimeBase tb, int
> flag) throws QTException
> {
>
> super(tb, flag);
>
> }
>
>
> public void execute() throws QTRuntimeException
> {
>
> try
> {
> if (Vars.DEBUG)
> System.out.println("Entered execute()");
>
>
> if (Vars.DEBUG)
> System.out.println("removing client from canvas
> and setting new one.");
>
> myQTCanvas.removeClient();
> myQTCanvas.setClient(qtp,new
> QDRect(dimension.width, dimension.height));
>
> if (Vars.DEBUG)
> System.out.println("Setting new movie");
>
>
> mc.setMovie(getMovieFromLocation(getNextMovieName()),
> myQTCanvas.getPort(), new QDPoint(0,0));
>
> if (Vars.DEBUG)
> System.out.println("Resizing qtp");
>
> qtp.setDisplayBounds(new QDRect(dimension.width,
> dimension.height));
>
> // Check if only film segment required
> if (gm.getMovieDuration() != 0)
> {
> if (Vars.DEBUG)
> System.out.println("Movie segment : " +
> gm.getMovieURL() + "\t From: " +
> gm.getMovieStartTime() + "\t Dur: " +
> gm.getMovieDuration());
>
>
> mc.getMovie().setPreviewTime(gm.getMovieStartTime(),
> gm.getMovieDuration());
> mc.getMovie().setPreviewMode(true);
> mc.getMovie().playPreview();
>
> }
> else
> {
> mc.getMovie().setPreviewMode(false);
> mc.getMovie().start();
> }
> theMoviesExtremeCallback.cancelAndCleanup();
> theMoviesTimeBase = mc.getMovie().getTimeBase();
> theMoviesExtremeCallback = new
> TimeBaseExtremesCallBack(theMoviesTimeBase,
> StdQTConstants.triggerAtStop ); // this callback is
> triggered when the movie stops
> theMoviesExtremeCallback.callMeWhen ();
>
>
> HideFSWindow hw = new HideFSWindow (w, myQTCanvas);
> w.addMouseListener (hw);
> myQTCanvas.addMouseListener (hw);
>
> System.out.println("\n\n=============");
> System.out.println("Next Movie:\n=============");
> Runtime rt = Runtime.getRuntime();
> System.out.println("Free Memory: " +
> rt.freeMemory());
> System.out.println("TotalMemory (JVM): " +
> rt.totalMemory());
>
>
> }
> catch (StdQTException
> e){System.out.println(e.getMessage());}
> catch (QTException
> qte){System.out.println(qte.getMessage());}
> catch (Exception ex) {System.out.println("Exception:
> " + ex.getMessage());}
>
> if (Vars.DEBUG)
> System.out.println("Showing Window...");
> }
> }
>
> static class HideFSWindow extends MouseAdapter
> {
> HideFSWindow (FullScreenWindow w, QTCanvas c)
> {
> this.w = w;
> this.c = c;
> }
>
> private FullScreenWindow w;
> private QTCanvas c;
>
> public void mousePressed (MouseEvent me)
> {
> c.removeClient();
> w.hide();
> QTSession.close();
> System.exit(0);
> }
> }
>
>
> }
>
>
>
> ________________________________________________________________
> Nokia 5510 looks weird sounds great.
> Go to http://uk.promotions.yahoo.com/nokia/ discover and win it!
> The competition ends 16 th of December 2001.
> _______________________________________________
> quicktime-java mailing list
> email@hidden
> http://www.lists.apple.com/mailman/listinfo/quicktime-java


References: 
 >Help - Processor Usage Rockets and playback flickers??? (From: STEVEN JOHNSTON <email@hidden>)



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.