Question:
How can I play MPEG video in Director?
Answer:
There are a number of ways, no one is any better than another, and it will be different on the Mac and the PC. Having said that, here are the 4 most common solutions.
1. Use an Xtra. To see a list of currently available ones click here. This makes it easier to work with, good product support, but many are not cross platform.
2. Use ActiveX controls. This is only a solution on the PC, but a behavior to control the Microsoft Active Movie ActiveX component can be found here. Note that this is more limited than an Xtra, but is free and works well for standard playback.
3. Use QuickTime. This is another that is for one platform only. On the Mac QuickTime supports MPEG, but on the PC you are out of luck.
4. Use MCI calls. This is another PC only one, but works fairly well. Note that the playback engine is only 16 bit, so performance may not be as good as other solutions and it calls directly from the system so control is limited. Also, Microsoft no longer supports these calls. For MCI behaviors click here.
Try them out and choose what works best for you, but remember that MPEG can act differently on every platform, so test on a wide variety of machines!!
这里是所需要的behavior:
--Copyright 1999 Chuck Neal
--chuck@mediamacros.com
--If you find this code helpful, send me an e-mail and let me know. :-)
property initialMovie, spriteNum, command, whenGo, movieSprite
on getPropertydescriptionList me
p_list = [:]
if (sprite the currentSpriteNum).member.type = #activeX then
addProp p_list, #initialMovie, [#format : #string, #default : "mediasample.mpg", #comment : "Default Movie Relative to the Director Movie:"]
else
addProp p_list, #command, [#format : #symbol, #default : #PlayMovie, #range : [ #PlayMovie,#FastF,#StopPlay, #RestartMovie, #pauseMovie ], #comment : "What button is this?"]
end if
return p_list
end
on beginSprite me
if (sprite spriteNum).member.type = #activeX then
sprite(spriteNum).filename = the moviePath & initialMovie
sprite(spriteNum).showdisplay = false
sprite(spriteNum).showPositionControls = false
sprite(spriteNum).showControls = false
sprite(spriteNum).showSelectionControls = false
sprite(spriteNum).showTracker = false
sprite(spriteNum).autoRewind = false
sendAllSprites(#IAmMovie, spriteNum)
if sprite(spriteNum).autostart = true then
command = #playMovie
else
command = #stopPlay
end if
end if
end
on mouseUp me
if (sprite spriteNum).member.type = #activeX then
pass
else
case command of
#PlayMovie :
sprite(movieSprite).command = #playMovie
run(sprite movieSprite)
#FastF :
sprite(movieSprite).command = #playMovie
sprite(movieSprite).rate = 1
run(sprite movieSprite)
#StopPlay :
sprite(movieSprite).command = #StopPlay
stop(sprite movieSprite)
#RestartMovie :
sprite(movieSprite).command = #playMovie
stop(sprite movieSprite)
sprite(movieSprite).fileName = sprite(movieSprite).fileName
#PauseMovie :
sprite(movieSprite).command = #PauseMovie
pause(sprite movieSprite)
end case
end if
end
on mouseDown me
if (sprite spriteNum).member.type = #activeX then
pass
else
case command of
#FastF :
sprite(movieSprite).command = #FastF
sprite(movieSprite).rate = 3
put sprite(movieSprite).rate
end case
end if
end
on IAmMovie me, whatSprite
movieSprite = whatSprite
end
on getBehaviorDescription me
describe = "This is a pretty simple script to use the activeMovie ActiveX control. You are not going to ahve as much flexibility as you would with an Xtra, but it is pretty sound for just playing back a movie." & return & "Drop this on you activeX control as well as the play, ff, stop, pause, and restart buttons. You may also want ot open up the activeX element and assign properties manually for things like size (double, half, etc). Remember that the only supported sizes are double, half, quarter, etc, not odd sizes. Also, the sprite must be set to the maximum size or larger than the movie or it will be cropped."
end
由于论坛变形, 把最后一段handler 分出来, 使用时, 请同时copy 这一段。
以上内容出自:
www.mediamacros.comTo LoveKing
如果你愿意,可以帮助大家翻译过来吗?我可以帮助你校对。让我们大家来帮助大家, 好不好?