|
|
|
Aug 29th, 2007.
|
MPEG3 Plugin For Squeak
|
Aug 2002
I'm pleased to say the mpeg player is now part of the offical 3.2 Squeak image.
The plugin can be found at ftp://st.cs.uiuc.edu/Smalltalk/Squeak/3.2/mac/carbonplugins/. for the macintosh carbon version, other versions for windows and unix also exist in the offical ftp sites
Current smalltalk source code is in the Squeak 3.2 image
Current C source code is in the Squeak SVN source tree.
Note that if you build your own VM, you could make the plugin as part of the VM to avoid fiddling with additional files..
Also see Bob Hartwig releases SqueakAmp a cool Morphic MP3 player
Historical Information
Information below is here for historical purposes, and is not current or perhaps supported.
Dec 12th, 2001
The plugin goes to v1.2, I removed the check for mpg file extensions.
You can find the plugins (at least the mac ones at the Squeak FTP site)
The C source code as a zip file
This also gets posted to the Squeak source forge site at some point.
Oct 8th, 2001
A carbon plugin for OS-X, The macintosh version 1.1 carbon (as a sit file): plugin.
Only works with a Carbon VM.
2nd, 2001
Change set 4110 brings a new MPEG Player by John Maloney. It is based on the plugin primitives but provides better performance for viewing movies and listening to sound in Morphic, as compared to the Morphic players originally shipped last year (2000). Don't forget to get the V1.1 of the plugin, it does have improved performance for movies.
Try this MPEGMoviePlayerMorph new openInWorld
May 2nd, 2001
A new plugin for the macintosh is released V1.1 It should be faster for video. Source changes are bundled in the source code, Linux and Windows implementers should update the plugin test and recompile (I didn't test the code for windows or linux so it might not work?).
For a Squeak 3.x image which is current you only need the plugin for your platform, basic Smalltalk code should be in the image.
The macintosh version 1.1 (as a sit file): plugin.
The Windows version based on 1.0 code http://spair.swiki.net/Mpeg3Plugin
The C source code (1.1) as a zip file
Some players which might not be in your image
The BlobMPEG player BlobMPEGMorphJMM.4.cs.
Bob Hartwig SqueakAmp a cool Morphic MP3 player
April 19th, 2001.
I should point out that I *believe* in the Squeak 3.1 update stream you will find SqC has now included all the MPEG change sets, so you don't need to get them or the fixes from here, in fact by doing that you might break something since some fixes have come out for the MPEG players which are included below. You still will need the plugin.
Feb21st 2001
"Stephen Pair" <spair@advantive.com> writes
I've had a few requests for the Mpeg3Plugin sources for Windows...I guess that it was never integrated into the other sources...anyway I've posted this code at: http://spair.swiki.net/Mpeg3Plugin Can you add a link to that page from your Mpeg3Plugin pages
Jan 23nd 2001
{ONLY DOWNLOAD THESE IF YOU ARE SURE YOU NEED THEM. Squeak 3.1 should have all the Smalltalk source code}
I've consolidated the MPEG Smalltalk software into one change set. MPEGJan2001Consolidation.2.cs You still need the plugin which on Jan 23rd had the source restructured based on Linux/Unix feedback. Also see Bob's software below and the BlobMPEG player BlobMPEGMorphJMM.4.cs
A new version of the source with some tuning will be posted shortly.
Dec 20th
Bob Hartwig releases SqueakAmp a cool Morphic MP3 player, but you still need the plugin below.
Nov 20th
Yet another change set to fix problems playing just audio files in morphic
Nov 19th
A change set to fix some problems with the Nov 18th release:
The morphic player should restart correctly if you start and stop your image
If you play a mpeg movie or audio file to the end, now you can reposition the slider and restart the movie
Nov 18th
Rollout of changes:
Incorporated changes to make this compile on Linux, macintosh, and Windows. More work is still pending. For the Smalltalk code we changed the follow:
Added logic to set the color model based on endiness
Changed C define names to better match what we are doing
Reworked accessors for all Mpegfile attributes for accesibility in the MpegPlayer
Added accessors for more instance variables
Added logic to set sound volume
Fiddled with delay logic once again
Will drop more than 3 frames if video is too slow
Rewrote logic that dealt with frame forward/backwards logic
Added suggestions to play full screen if desired
Added sanity checks to the C code
Thanks to:
Bert Freudenberg
Lex Spoon
Stephen Pair
Karl Ramberg
Douglas Brebner
(hope I didn't miss anyone)
Nov 3rd. We are pending code changes to encorporate the work that was done to get the C source to work on windows.
Note we have relicensed the GPL code as LGPL or optionally you can use the Squeak License (If you need to see the approval letter from the original author, please contact me) If you retreived the 'C' source code before Nov 3rd at 23:00 UTC then you should get the current version and toss the earlier downloaded source.
This Squeak for the Macintosh plugin allows you to play MPEG3 video or audio within Squeak. It uses a C based library for the primitives to allow Squeak based applications access to decoded MPEG Video and Audio.
The supplied player is primitive and I'm hoping some skins will be created (Karl Ramberg has been posting some changes sets) and other ports to other platforms will be done to round out the platforms it can run on. The original C code is good quaility C code and so it should not be hard to port to the ARM for instance.
Oct 20th I extracted the Smalltalk code since it's under the Squeak-L, and added an accessor for the MpegFile, so now you need to download the Squeak change set, then either the plugin, or the C code and build your own.
The Smalltalk code: a change set (MPEGPlayerJMM.10.cs) also the change set for the Morphic Player by Karl Ramberg <karl.ramberg@chello.se> (Nov 18th i think you should be able to overlay these change sets with your past changesets)
The macintosh version: plugin. (Nov 18th better error checking)
The C source code as a zip file
(Nov 2nd news flash)
A Windows version of the plugin can be downloaded at:
http://spair.swiki.net/.uploads/Mpeg3Plugin.dll
Some code example of usage follow, at the end is a single Morphic usage with a SketchMorph. Dig deeper to find the controls for stop, forward, play, set frame etc. Or ask me. Please note that Disney is working on some changes to the Sound player to make playing streams of sound easier and better!
"Find a file"
MPEGFile isFileValidMPEG: 'randomalien.mpg'.
"Explore the file"
| foo |
foo _ MPEGFile openFile: 'randomalien.mpg'.
foo hasVideo.
foo hasAudio.
foo endOfVideo: 0.
foo endOfAudio: 0.
foo audioChannels: 0.
foo audioSamples: 0.
foo audioGetSample: 0.
foo audioSampleRate: 0.
foo videoFrameRate: 0.
foo videoGetFrame: 0.
foo audioGetSample: 0.
foo getTimeCode.
foo videoPreviousFrame: 0.
foo videoSetCPUs: 1.
foo videoSetFrame: 44 stream: 0.
foo setMMX: true.
foo audioSetSample: 44 stream: 0.
foo totalAudioStreams.
foo totalVideoStreams.
foo videoFrames: 0.
foo videoFrameHeight: 0.
foo videoFrameWidth: 0.
foo seekPercentage: 0.5.
foo getPercentage.
foo videoSetCPUs: 1.
foo setMMX: true.
foo closeFile.
-----------------------------------
"Simply get the video start at 700 and run 50 frames then debug"
"Better code is in the player, don't use this code, but it's an example"
| foo x y counter fum |
foo _ MPEGFile openFile: 'randomalien.mpg'.
stream _ 0.
counter _ 0.
y _ foo videoFrameHeight: stream.
x _ foo videoFrameWidth: stream.
fum _ Form extent: x@y depth: 32.
frames _ foo videoFrames: stream.
foo videoSetFrame: 700 stream: stream.
[foo endOfVideo: stream] whileFalse:
[foo videoReadNextFrameInto: fum bits
width: fum width height: fum height stream: stream.
fum displayOn: Display.
(counter _ counter + 1) == 50 ifTrue: [self halt]].
foo closeFile.
-----------------------------------
"Play the audio"
"There is more than one way to do this"
"This is my first technically correct try"
"DO not use this code, better code is in the player"
| foo buffer sound soundOther |
foo _ MPEGFile openFile: 'randomalien.mpg'.
channels _ foo audioChannels: 0.
sampleRate _ foo audioSampleRate: 0.
totalSamples _ foo audioSamples: 0.
buffer _ ByteArray new: 1024*1024*1.
SoundPlayer startPlayerProcessBufferSize: 8192 rate: sampleRate stereo: true.
result _ foo audioReadBuffer: buffer stream: 0 channel: 0 samples: 1024*1024//2.
sound _ SampledSound samples:
(SampledSound convertBytesTo16BitSamples: buffer mostSignificantByteFirst: true)
samplingRate: sampleRate.
result _ foo audioReReadBuffer: buffer stream: 0 channel: 1 samples: 1024*1024//2.
soundOther _ SampledSound samples:
(SampledSound convertBytesTo16BitSamples: buffer mostSignificantByteFirst: true)
samplingRate: sampleRate.
sound _ MixedSound new
add: sound pan: 0;
add: soundOther pan: 1.0.
sound play
-----------------------------------
"Ok make it simple for Audio"
| foo |
form _ Form extent: 320@240 depth: 16.
foo _ MPEGPlayer playFile: 'randomAlien.mpg' onForm: form.
foo playAudioStreamWaitTilDone: 0.
-----------------------------------
"Ok make it simple for Video"
| foo |
form _ Form extent: 320@240 depth: 32.
foo _ MPEGPlayer playFile: 'randomAlien.mpg' onForm: form.
foo playVideoStreamWaitTilDone: 0.
-----------------------------------
"Play the video in the background"
| foo |
form _ Form extent: 320@240 depth: 16.
foo _ MPEGPlayer playFile: 'randomAlien.mpg' onForm: form.
foo playVideoStream: 0.
foo inspect.
-----------------------------------
"Play both in the background"
| foo |
form _ Form extent: 320@240 depth: 16.
foo _ MPEGPlayer playFile: 'randomAlien.mpg' onForm: form.
foo playStream: 0.
foo inspect.
-------------------------
" In Morphic do "
| foo |
form _ Form extent: 320@240 depth: 32.
morph _ SketchMorph withForm: form.
morph openInWorld.
foo _ MPEGPlayer playFile: 'randomAlien.mpg' onMorph: morph.
foo morph: morph.
foo playStream: 0.
foo inspect.
|