Karl Ramberg uploaded a new version of Movies to project Etoys:
http://source.squeak.org/etoys/Movies-kfr.3.mcz ==================== Summary ==================== Name: Movies-kfr.3 Author: kfr Time: 27 May 2011, 3:07:03 pm UUID: 6e866d96-bfa6-644d-a4f6-b6c37739c4b1 Ancestors: Movies-kfr.2 Fix to keep reference to external video file over project saves =============== Diff against Movies-kfr.2 =============== Item was changed: ----- Method: MPEGDisplayMorph>>closeFile (in category 'file open/close') ----- closeFile "Close my MPEG file, if any." mpegFile isNil ifFalse: [ + [mpegFile closeFile] ifError:[ nil]. - mpegFile closeFile. mpegFile := nil. frameBuffer := nil]. subtitles := nil. self changed. ! Item was changed: ----- Method: MPEGDisplayMorph>>mpegFileIsOpen (in category 'file open/close') ----- mpegFileIsOpen + "Answer true if I have an open, valid MPEG file handle. If the + handle is not valid, try to re-open the file." + | fileName | + mpegFile + ifNil: [^ false]. + mpegFile fileHandle + ifNil: ["try to reopen the file, which may have been saved in a + snapshot " + fileName := mpegFile fileName. + self openFileNamed: mpegFile fileName. + mpegFile + ifNil: [self inform: 'Path changed. Enter new one for: ' translated + , fileName. + self openMPEGFile. mpegFile ifNil:[^false]]. + mpegFile fileHandle + ifNil: [mpegFile := nil]]. + ^ mpegFile notNil! - "Answer true if I have an open, valid MPEG file handle. If the handle is not valid, try to re-open the file." - - mpegFile ifNil: [^ false]. - mpegFile fileHandle ifNil: [ - "try to reopen the file, which may have been saved in a snapshot" - mpegFile openFile: mpegFile fileName. - mpegFile fileHandle ifNil: [mpegFile _ nil]]. - ^ mpegFile notNil - ! Item was changed: ----- Method: MPEGDisplayMorph>>startPlaying (in category 'commands') ----- startPlaying "Start playing the movie at the current position." | frameIndex | self stopPlaying. stopFrame _ nil. self mpegFileIsOpen ifFalse: [^ self]. - (FileStream isAFileNamed: mpegFile fileName) ifFalse: [ - self inform: 'Path changed. Enter new one for: ' translated, (FileDirectory localNameFor: mpegFile fileName). - self openMPEGFile. - (self openFileNamed: (mpegFile fileName)) ifFalse:[ ^self inform:'No valid file selected' translated] - ]. + mpegFile hasAudio ifTrue: [mpegFile hasVideo ifTrue: ["set movie frame position from soundTrack position" soundTrack reset. "ensure file is open before positioning" soundTrack soundPosition: (mpegFile videoGetFrame: 0) asFloat / (mpegFile videoFrames: 0). "now set frame index from the soundtrack position for best sync" frameIndex _ ((soundTrack millisecondsSinceStart * desiredFrameRate) // 1000). frameIndex _ (frameIndex max: 0) min: ((mpegFile videoFrames: 0) - 3). mpegFile videoSetFrame: frameIndex stream: 0]. SoundPlayer stopReverb. soundTrack volume: volume. soundTrack repeat: repeat. soundTrack resumePlaying. startFrame _ startMSecs _ 0] ifFalse: [soundTrack _ nil. startFrame _ mpegFile videoGetFrame: 0. startMSecs _ Time millisecondClockValue]. running _ true! _______________________________________________ etoys-dev mailing list [hidden email] http://lists.squeakland.org/mailman/listinfo/etoys-dev |
Free forum by Nabble | Edit this page |