In this project we are gonna take a look at this movieFlow project. This is the first of the first beta in line. So don’t expect a totally bug free program! :P

The goal is to make a part of the total ‘media player’ concept like shown in the topic “concept media ui design and adobe director“. This little program should also be developed in adobe director, for the main reasons, fast and easy flash integration.

movieflow_beta_700px.jpg


Before we can take a look at the code we make a shopping-list!
What you need to make the program working is:

  • Wii-remote compatible bluetooth 2.0 dongle like we use, the MSI BToes 2.0 using BlueSoleil ( search google or look at ‘this site’ for a list of working dongles.
  • Some connection program like Bluesoleil that mostly comes with the dongle
  • And off course a standard wii-remote

First things first…
1) The next thing is to make a connection between the wii-mote and computer.
Because we use bluesoleil, the next few images explains how you can set up you connection:

First, start up the BlueSoleil software and activate your adapters if needed.

bs2.jpg

Then hit the 1+2 buttons on your Wiimote and click the center orange circle. It will take a few seconds and then find it.
Note: Make sure that the 4 LEDs on the bottom of the Wiimote are blinking during this whole process. Since the Wiimotes only stay on discover mode for several seconds, you can either hold down the 1+2 buttons the whole time or press them every few seconds.

If BlueSoleil does not detect your Wiimote, Unplug your bluetooth device and plug it back in. Then press the center orange circle and try again.

bs3.jpg

Right click the Wiimote (NINTENDO-RVT-CNT-01) that shows up and click Refresh Services.

bs4.jpg

Click the Bluetooth HID button that shows up at the top and you are done!

bs5.jpg

Thats all! You now have a connection!

2) Now we can get started with director or simply use the movieFlow.exe

Download the movieFlow.zip

This download contains the basic program and folder structure.
Simply put your files into the right folders shown below:

In this first beta the folder structure should be like:

C:\labcoding\MovieFlow\movieflow.exe
C:\labcoding\MovieFlow\xml\albuminfo.xml

put all your avi (xvid / divx) movies in the folder:
C:\labcoding\MovieFlow\Movies\

the (beta)filesystem Works only one folder deep..
So to get it working you should use the next filelocations:

put the movies into:
C:\labcoding\MovieFlow\Movies\

the coverart:
C:\labcoding\MovieFlow\Movies\myMovie\front.jpg

the movie:
C:\labcoding\MovieFlow\Movies\myMovie\filename.avi

Off course the path C:\labcoding\MovieFlow\ should be relative

3) To start developing and adjusting the code you need some extra (director) stuff

  • first you need adobe director mx 2004 or later.
  • next you need to update the xtra flash asset.x32 for our flash 8 media files, in the folder C:\Program Files\Macromedia\Director MX 2004\Configuration\Xtras\Media Element\Flash Asset you can get the update for free from the adobe website.
  • the next extras you need to place into the folder: C:\Program Files\Macromedia\Director MX 2004\Configuration\Xtras
    • budapi.x32 (not free! look at: http://www.mediamacros.com/item/item-930154413/ )
    • MediaPlayerExp.x32 and MediaPlayerExpDialog.x32 (also not free! look at: http://www.starsoftmultimedia.com/xtras/MediaPlayer/index.php)
    • wiiMote.x32 (free download at: http://www.glisferox.co.uk/index.php?page=wiimote)

Note:The budapi.x32 will be used to make a listing for your content. For testing you could use a static file, or you can simply find an alternative.

Note:The MediaPlayerExp.x32 and MediaPlayerExpDialog.x32 are needed to make video files and divx working in director. This will not be used to make audio files working. So the AlbumFlow program we discuss in another topic does not use this xtra’s! You can also program to load the files externally or find different free alternatives.

4) Start programming:

At the bottom you can find basically all the code in director we used for this projects MovieFlow and AlbumFlow. The director files will be soon ready for download.

global myPath
 global wii
 global myFile
on preparemovie
-- seting the globals
 _global.blendstart = 30
 _global.blendover =  100
_global.mouseDownbackColor =   8
 _global.mouseUpbackColor  =    0
sprite("sluitenDark").blend = _global.blendstart
 _global.aantalNummers = 0
_global.myVolume = 70 -- max 100 for sprite("video").volume
_global.myMp3path = _movie.path & "Movies\"
 --set _global.Folders = baFolderList(_global.myNewMp3path)
 _global.Folders = baFolderList(_global.myMp3path)
--save path text to xml
 WriteOutXMLFiles
end
on StartMovie
-- start the wii xtra
 wii = new(xtra "gfWiiMote")
put wii.Init()
 put wii.Count()
 wii.SetButtonHandler(#onWiiButtons)
 wii.SetMotionHandler(#onWiiMotion)
 wii.Start(0)
 wii.SetLeds(0, 0, 1, 0, 1)
 wii.RequestMotionData(0)
-- check if the default path is existing
 if _global.Folders = [] then
 _player.alert("There is nothing in the default path: Movies!")
 end if
end
-- explaining the wii-remote buttons
 -- 1    = button 1
 -- 2    = button 2
 -- 4    = backbutton
 -- 8    = button A
 -- 16   = min
 -- 128  = home
 -- 256  = left
 -- 512  = right
 -- 1024 = up
 -- 2048 = down
 -- 4096 = plus
on onWiiButtons(dev, but, state)
put but
 case but of
 1:
 wii.SetLeds(0, 1, 0, 1, 0)
 2:
 wii.SetLeds(0, 0, 1, 0, 1)
 4:
 if state then
 Fullscreen7
 end if
 8:
 if state then
 enterDvd
 end if
 128:
 if state then
 gotoHomeAction
 end if
 256:
 if state then
 if _movie.framelabel = "dvd" then
 nothing
 -- rewind
 else
 nextDvd
 end if
 end if
 512:
 if state then
 if _movie.framelabel = "dvd" then
 nothing
 -- forward
 else
 previousDvd
 end if
 end if
 16:
 if state then
 volumeDown
 end if
1024:
 if state then
 --up
 end if
2048:
 if state then
 --down
 end if
4096:
 if state then
 volumeUp
 end if
 end case
end
-- sound down
 on volumeDown me
 timeOut().new("timeOutDown", 10, #VolumeDownAction, me)
 end
-- sound up
 on volumeUp me
 timeOut().new("timeOutUp", 10, #VolumeUpAction, me)
 end
-- next Movie
 on nextDvd me
 timeOut().new("timeOutnextDvd", 10, #nextDvdAction, me)
 end
on nextDvdAction me
 gFlashRoot = sprite("flash").getVariable("_level0",0)
 gFlashRoot.previous()
timeOut("timeOutnextDvd").forget()
 end
-- previous Movie
 on previousDvd me
 timeOut().new("timeOutpreviousDvd", 10, #previousDvdAction, me)
 end
on previousDvdAction me
 gFlashRoot = sprite("flash").getVariable("_level0",0)
 gFlashRoot.next()
timeOut("timeOutpreviousDvd").forget()
 end
-- enter dvd action
 on enterDvd me
 timeOut().new("timeOutenterDvd", 10, #enterDvdpreAction, me)
 end
on enterDvdpreAction me
enterDvdAction
 timeOut("timeOutenterDvd").forget()
 end
-- fullscreen
on Fullscreen7 me
 timeOut().new("FullscreenName7", 10, #FullscreenHandler7, me)
 end
on FullscreenHandler7 me
 if _movie.framelabel = "dvd" then
 if sprite("video").FullScreen = 1 then
 sprite("video").FullScreen = 0
 else
 sprite("video").FullScreen = 1
 end if
 end if -- framelabel
 timeOut("FullscreenName7").forget()
 end
-- motion functions
on onWiiMotion(dev, x, y, z)
 --  _movie.sprite(1).color = color(128 + x, 128 + y, 128 + z)
gFlashRoot = sprite("flash").getVariable("_level0",0)
if x < -20 then
 nextDvd
 end if
 if x > 20 then
 previousDvd
 end if
 end
--saveText
on WriteOutXMLFiles
 if objectP(myFile) then set myFile = 0  --Delete the instance if it already exists
 myFile = new(xtra "fileio")    -- Create an instance of FileIO
 openFile (myFile, the moviePath &"XML\albuminfo.xml",0)--Open the file with R/W access
 delete(myFile) --deletes the file
 createFile (myFile, the moviePath &"XML\albuminfo.xml") --creates the file again
 openFile(myFile,the moviePath &"XML\albuminfo.xml",0) --Open the file with R/W access
-- hier de xml data
 mySaveString ="<artworkinfo>"
 --& _global.textToBeWritten & "</artworkinfo>"
writeString(myFile,mySaveString) --writes text to the file
_global.listOfFolders = baFolderList(_global.myMp3path)
 _global.nFolders = count(_global.listOfFolders)
repeat with mapcount = 1 to _global.nFolders
 _global.thisFolderName = _global.listOfFolders[mapcount]
_global.textToBeWritten = "<albuminfo>" & "<artLocation>" & _global.thisFolderName & "\front.JPG" & "</artLocation>" & "<trackName>" & "txt" & "</trackName>" & "<artist>" & "txt" & "</artist>" & "<albumName>" & _global.thisFolderName & "</albumName>" & "<httptype>" & _global.myMp3path & "</httptype>" & "</albuminfo>"
--openFile(myFile,the moviePath &"XML\albuminfo.xml",0) --Open the file with R/W access
 setPosition(myfile,getLength(myFile))  -- Sets position to end of file
 writeString(myFile, _global.textToBeWritten)  -- Appends text to the file
 --alert "Status: "&error(myFile,status(myFile))  -- Displays error
end repeat
setPosition(myfile,getLength(myFile))  -- Sets position to end of file
 writeString(myFile, "</artworkinfo>")  -- Appends text to the file
 --alert "Status: "&error(myFile,status(myFile))  -- Displays error
 closeFile(myFile) -- Close the file
 myFile = 0 -- Dispose of the instance
fileObj = new(xtra "FileIO")
 openFile(fileObj, "XML\albuminfo.xml", 1)
 text = readfile(fileObj)
 closeFile(fileObj)
end
-- go to 'home'
 on gotoHomeAction me
if _movie.framelabel = "dvd" then
sprite("video").stop()
 go "main"
 end if
end
-- volume down action
 on VolumeDownAction
 if _global.myVolume > 4 then
 _global.myVolume = _global.myVolume - 5
 end if
 timeOut("timeOutDown").forget()
 end
-- volume up action
 on VolumeUpAction
 if _global.myVolume < 96 then
 _global.myVolume = _global.myVolume + 5
 end if
 timeOut("timeOutUp").forget()
 end
-- enter the specific dvd
 on enterDvdAction
 if member("albumNaam").text <> "" then
 if _movie.framelabel = "main" then
 _movie.go("dvd")
_global.test = _global.myMp3path & member("albumNaam").text
 _global.selectedAlbum = baFileList( _global.test, "*.avi" )
sprite("video").LoadFile( _global.myMp3path & member("albumNaam").text & "\" & string(getAt(_global.selectedAlbum, 1)))
 sprite("video").Play()
 end if
end if
 end -- end enterAlbumAction
on enterframe me
if _movie.framelabel = "main" then
if (_key.keyPressed("k")) then
 someHandler5
 end if
end if -- _global.selectedAlbum
if (_key.keyPressed("p")) then
 if _movie.framelabel <> "main" then
 set _global.getFirstFile = baFileList( _global.moviepath & member("menuItemSelected").text & "\", "*.avi" )
 sprite("video").LoadFile( _global.myMp3path & member("albumNaam").text & "\" & string(getAt(_global.selectedAlbum, 1)))
sprite("video").Play()
else
 nothing
 end if
 end if
if _movie.framelabel = "dvd" then
 sprite("video").Volume = _global.myVolume
 end if
end -- end enterframe
-- cleaning up wii connection
 on StopMovie
wii.SetLeds(0, 0, 0, 0, 0)
 wii.Stop(0)
 wii.CleanUp()
end
Be Sociable, Share!