Re: [Pyobjc-dev] QTKit.QTMovie .play() question
Brought to you by:
ronaldoussoren
|
From: Luc H. <lu...@ho...> - 2009-02-13 08:55:46
|
On 13 févr. 09, at 03:12, Armando Rivera wrote:
> I'm trying to play an mp3 file use QTMovie's .play() method, and no
> matter what I've tried I only get approximately 2 seconds of output.
> Is there something that I'm missing?
A run loop, like this for example:
=======================
#!/usr/bin/env python
from QTKit import QTMovie
from AppKit import NSSound, NSRunLoop
from Foundation import NSDate
movie, error = QTMovie.movieWithFile_error_("Happy.mp3", None)
if movie is not None:
duration = movie.duration().timeValue / movie.duration().timeScale
print "QTMovie Media Length is %d Seconds." % duration
movie.play()
while movie.isPlaying():
NSRunLoop
.currentRunLoop().runUntilDate_(NSDate.dateWithTimeIntervalSinceNow_(1))
print movie.currentTime().timeValue /
movie.currentTime().timeScale
=======================
> If I uncomment the print
> movie.currentTime() call, I continue to receive the current position
> of the file, but no sound.
>
> Here is the code I'm trying:
>
> ================
> #!/usr/bin/env python
> from QTKit import QTMovie
> from AppKit import NSSound
>
> movie, error = QTMovie.movieWithFile_error_("Happy.mp3", None)
>
> if movie:
> print "QTMovie Media Length
> is",movie.duration().timeValue/movie.duration().timeScale,"Seconds."
> movie.play()
> while movie.isPlaying():
> # print movie.currentTime()
> pass
> else:
> print "Error Playing Media"
>
> #sound =
> NSSound.alloc().initWithContentsOfFile_byReference_("test.mp3", True)
> ##sound.retain()
>
> #if sound:
> # print "NSSound Media Length is",sound.duration(),"Seconds."
> # sound.setVolume_(100.0)
> # sound.play()
> # while sound.isPlaying():
> # print sound.currentTime()
> ================
>
> The commented section that uses NSSound works fine, and plays the mp3
> to the end.
>
> I need to use QTKit because I'll be generating clips from the source
> audio and exporting to new files.
>
> Thanks for any help.
>
> Armando Rivera
> --
> "Programming is like Poetry. Sometimes the words just escape you..."
> -me, to my manager.
>
> ------------------------------------------------------------------------------
> Open Source Business Conference (OSBC), March 24-25, 2009, San
> Francisco, CA
> -OSBC tackles the biggest issue in open source: Open Sourcing the
> Enterprise
> -Strategies to boost innovation and cut costs with open source
> participation
> -Receive a $600 discount off the registration fee with the source
> code: SFAD
> http://p.sf.net/sfu/XcvMzF8H
> _______________________________________________
> Pyobjc-dev mailing list
> Pyo...@li...
> https://lists.sourceforge.net/lists/listinfo/pyobjc-dev
|