Platforms to show: All Mac Windows Linux Cross-Platform

/MacControls/Quartz Composer Control/QCView Movie


Required plugins for this example: MBS MacBase Plugin, MBS MacOSX Plugin, MBS Main Plugin, MBS MacControls Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacControls/Quartz Composer Control/QCView Movie

This example is the version from Thu, 6th Apr 2016.

Project "QCView Movie.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control Rectangle1 Inherits Rectangle
ControlInstance Rectangle1 Inherits Rectangle
End Control
Control PauseBtn Inherits PushButton
ControlInstance PauseBtn Inherits PushButton
EventHandler Sub Action() if not playing or stoped then exit if not paused then ' QCin("SelStart", QCout("MoviePosition") ) //put selection at position QCin("SelDuration",0.003) //while method to make pause me.Caption = "Resume" paused = true ' else ' QCin("SelStart", QCout("MoviePosition") ) QCin("SelDuration",0 ) //playing all me.Caption = "Pause" paused = false ' end if exit sub // brut method, sound in background : if v.isRendering and not v.isPausedRendering then v.pauseRendering me.Caption = "Resume" else v.resumeRendering me.Caption = "Pause" end if End EventHandler
End Control
Control PlayBtn Inherits PushButton
ControlInstance PlayBtn Inherits PushButton
EventHandler Sub Action() if txt.Text ="" then exit //Play Movie : Play(txt.Text) End EventHandler
End Control
Control StopBtn Inherits PushButton
ControlInstance StopBtn Inherits PushButton
EventHandler Sub Action() //reset Movie Stop End EventHandler
End Control
Control txt Inherits TextField
ControlInstance txt Inherits TextField
End Control
Control ckloop Inherits CheckBox
ControlInstance ckloop Inherits CheckBox
End Control
Control OpenBtn Inherits PushButton
ControlInstance OpenBtn Inherits PushButton
EventHandler Sub Action() dim d as openDialog = new openDialog dim f as folderitem = d.showModalWithin(self) if f = nil then Return txt.Text = f.UnixpathMBS Play(txt.Text) End EventHandler
End Control
Control bar Inherits ProgressBar
ControlInstance bar Inherits ProgressBar
End Control
Control Slider1 Inherits Slider
ControlInstance Slider1 Inherits Slider
EventHandler Sub ValueChanged() val = me.value /100 QCin("Alpha",val) End EventHandler
End Control
Control Label1 Inherits Label
ControlInstance Label1 Inherits Label
End Control
Control Overlaybtn Inherits PushButton
ControlInstance Overlaybtn Inherits PushButton
EventHandler Sub Action() //load image (or movie) overlay : dim NSImage as NSImageMBS = new NSImageMBS(LogoMBS(500)) QCin("Image",NSImage) 'QCin("Image",txt2.text) Slider1.Enabled = True End EventHandler
End Control
Control Timer2 Inherits Timer
ControlInstance Timer2 Inherits Timer
EventHandler Sub Action() //restart to the beginning : if QCout("MoviePosition") = 0.0 then QCin("SelDuration",0) me.Mode = 0 end if End EventHandler
End Control
Control Timer1 Inherits Timer
ControlInstance Timer1 Inherits Timer
EventHandler Sub Action() //setting Movie position & duration from the patch file : if position < 1 then duration =QCout("MovieDuration") bar.Maximum = duration end if position = QCout("MoviePosition") bar.Value = position dim second as string = str(round(position)) dim total as string = str(round(duration)) self.Title = second + " / " + total + " sec" if not ckloop.value then //Stopping the movie at the end : if second = total then Stop end if End EventHandler
End Control
Control view Inherits QCViewControlMBS
ControlInstance view Inherits QCViewControlMBS
EventHandler Sub Open() v = me.View //load quartz file : dim f as FolderItem = FindFile("quartz_patch.qtz") if f <> nil and f.Exists then if v.loadCompositionFromFile(f) then v.autostartsRendering=true else msgbox "cannot load patch file!" end if exception exit End EventHandler
End Control
Function FindFile(name as string) As FolderItem // Look for file in parent folders from executable on dim parent as FolderItem = app.ExecutableFile.Parent while parent<>Nil dim file as FolderItem = parent.Child(name) if file<>Nil and file.Exists then Return file end if parent = parent.Parent wend End Function
Sub Play(file as string) QCin("Movie",file) // Select and play the current file //Movie info : Timer1.Mode = 2 if playing then //Put the selection at the beginning : QCin("SelStart", 0 ) QCin("SelDuration", .003 ) Timer2.Mode = 2 //restart streaming end if if paused then paused = false PauseBtn.Caption = "Pause" end if stoped = false playing = true End Sub
Sub QCin(InputCommand as string, valeur as Variant) //make "input" port command (write) inside the patch file : if v.isRendering then if v.setValueForInputKey(valeur, InputCommand) then end if end if exception exit End Sub
Function QCout(valeur as string) As Variant //make "output" port command (read) inside the patch file : return v.valueForOutputKey(valeur) exception exit End Function
Sub Stop() QCin("Movie","") //empty file string from the quartz file position = 0 bar.Value = 0 Timer1.mode = 0 if paused then paused = false PauseBtn.Caption = "Pause" end if stoped = true End Sub
Property duration As Double
Property paused As Boolean = false
Property playing As Boolean = false
Property position As double
Property stoped As Boolean = true
Property v As QCViewMBS
Property val As double
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&Ablage"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Bearbeiten"
MenuItem EditUndo = "&Rückgängig"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "&Ausschneiden"
MenuItem EditCopy = "&Kopieren"
MenuItem EditPaste = "&Einfügen"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "&Alles auswählen"
End MenuBar
End Project

See also:

The items on this page are in the following plugins: MBS MacControls Plugin.


The biggest plugin in space...