Alan Kay said the computer is not a tool, but a new medium. In order for users to fully express themselves with a computer, it is important to integrate previous forms of expression into a more-powerful whole.
I have a working proof-of-concept to play any video file that QuickTime can handle in Squeak Smalltalk (or Pharo with slight modifications). This prototype is Mac-only.
If you have Gofer and Metacello installed, you can install the current version in Squeak 4.1 and Pharo 1.1.1 with:
((Smalltalk at: #ConfigurationOfFFI) project latestVersion) load.
Then, blow your mind by playing a video in-image with:
aURI := URI fromString: 'file:///path/to/video.ext'.
movie := QuickTimeMovie openMovieFromURI: aURI.
m := SqueakMovieMorph openOn: movie.
- click on the morph to play/stop the video
extra processes may be left running (FIXED)
Pharo 1.1.1: this will work after two errors – for both, go into the debugger and remove the isFinalizationSupported checks. (FIXED)
For our lazy/skeptical friends, here is a Flash video (.flv – H.264, 320 x 216, Millions; AAC,
Stereo, 22.050 kHz) playing in Squeak 4.1:
- fixed bug that left extra processes running when a movie was stopped and then restarted
- package now loads correctly in Pharo 1.1.1
OpenSophie (“software for writing and reading rich media documents in a networked environment”) did a lot of great stuff that never made it back to Squeak Smalltalk (on which it was built). I just ported mp3 playing to current Squeak/Pharo, and there are many more treasures to be unearthed.
Here’s how to get started:
- Download the last Squeak-based version here
- Start the image either:
- With a current Squeak VM passing it this changeset, which unlocks it for development (select to file in entire file from the menu that pops up). On the mac, you can do it like this from Terminal (n.b. Squeak VM Opt is inside the VM bundle):
"path/to/Squeak VM Opt" /path/to/Sophie.app/Contents/Resources/sophie.image /path/to/Sophie105PrepForDev.st
- By launching the Sophie one-click app
- Bring up a user interrupt (Cmd-. on the Mac)
- Click the “Debug” button
- In the debugger, DoIt the following:
- (World findA: SophieRootMorph) delete.
- Transcript open.
- SophieApplication open.
You will find yourself in a Squeak image with an OpenSophie application running in a SystemWindow.
If you rescue any code, share it with the community! And if you make sure to cut and paste the OpenSophie license into it (e.g. in a class comment), it seems you’re in the clear*.
* not legal advice. I’m not a lawyer.
UPDATE: To start exploring a book programmatically, evaluate:
SophieApplication singleton activeBook
Squeak’s VM has an mp3 plugin, but there doesn’t seem to be any access from the image. So I dug into OpenSophie (version 1 of which was based on Squeak) and yanked out some code.
You can now play mp3 files in Squeak and Pharo!
- Just load the SophiePort package from http://www.squeaksource.com/SPDProjectUpdates
song := StreamingMP3Sound onFileNamed: '/path/to/yourFavorite.mp3'.
- It works in Squeak 4.1 and Pharo 1.1.1 on Mac OS 10.6.5
- I am unclear about the license – Sophie has one license, the code itself seems to be SqueakL. Do your own investigation.
- There were checks like the following that had to be removed for Pharo 1.1.1: “WeakArray isFinalizationSupported ifFalse:[^anObject]“. I’m not sure of the implications of removing them
An amazing feature of Smalltalk is that you can create methods right from the debugger. This fits nicely with “write the code you wish you had.”
- First, you write a test calling whatever methods you want (even if they don’t exist)
- When you run the test, a debugger pops up with a create button
- Like magic, with a push of that button, a method skeleton appears in which you fill the implementation
Now this is where things get creepy… It’s after midnight, and I just want to finish one last thing. You see, I’ve been implementing a very basic Cucumber-like framework for acceptance tests in Squeak, and there’s just one thing left to do. I’ve got helper methods that turn given/then/when descriptions into methods that define the steps, like this:
As you can see, #given: transforms the description string into a camel case method name.
All I had left to do was handle the case where the method didn’t exist yet. In cucumber, templates are passed to the command line to be pasted into the step definition file. Oh, I’ve got it, the transcript is like command line output, I’ll paste it there! Let me just see what this debugger is about…
When I took a closer look, I started laughing and couldn’t stop…
Smalltalk handed me a magic Cucumber-step-definition-template-generator! I checked one more item on my todo list and clicked the magic button.