Platforms to show: All Mac Windows Linux Cross-Platform
/VLC/Show Video Images in Web App
Function:
Required plugins for this example: MBS VLC Plugin, MBS Util Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /VLC/Show Video Images in Web App
This example is the version from Sun, 4th Jul 2020.
Function:
Required plugins for this example: MBS VLC Plugin, MBS Util Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /VLC/Show Video Images in Web App
This example is the version from Sun, 4th Jul 2020.
Project "Show Video Images in Web App.xojo_binary_project"
Class App Inherits WebApplication
EventHandler Sub Open(args() as String)
DebugCopyLibs
End EventHandler
Sub DebugCopyLibs()
// copy vlc libs into app
// you need 32 bit version of VLC to have this work for 32bit app!
// and 64-bit libs for 64-bit app
#if TargetMacOS then
#if Target32Bit then
// we keep an old copy of version 2.0.9 for 32-bit
dim apppath as FolderItem = SpecialFolder.Applications.Child("VLC alt.app")
#else
Dim apppath As FolderItem = GetFolderItem("/Applications/VLC.app", folderitem.PathTypeNative)
#endif
if apppath<>Nil and apppath.Visible then
dim ContentsFolder as FolderItem = apppath.Child("Contents")
if ContentsFolder<>Nil and ContentsFolder.Visible then
dim MacOSFolder as FolderItem = ContentsFolder.Child("MacOS")
if MacOSFolder<>Nil and MacOSFolder.Visible then
dim TargetFolder as FolderItem = app.ExecutableFile.parent
dim LibFolder as FolderItem = MacOSFolder.Child("lib")
LibFolder.CopyFileTo TargetFolder
dim pluginsFolder as FolderItem = MacOSFolder.Child("plugins")
pluginsFolder.CopyFileTo TargetFolder
end if
end if
end if
#endif
#if TargetWin32 then
dim VideoLANFolder as FolderItem = SpecialFolder.Applications.Child("VideoLAN")
if VideoLANFolder<>Nil and VideoLANFolder.Visible then
System.DebugLog VideoLANFolder.NativePath
dim VLCFolder as FolderItem = VideoLANFolder.Child("VLC")
if VLCFolder<>Nil and VLCFolder.Exists then
dim ExecutableFolder as FolderItem = app.ExecutableFile.parent
dim libvlc as FolderItem = VLCFolder.Child("libvlc.dll")
libvlc.CopyFileTo ExecutableFolder
dim libvlccore as FolderItem = VLCFolder.Child("libvlccore.dll")
libvlccore.CopyFileTo ExecutableFolder
dim pluginsFolder as FolderItem = VLCFolder.Child("plugins")
dim destPluginsFolder as FolderItem = ExecutableFolder.Child("plugins")
// copy whole folder
dim w as new WindowsFileCopyMBS
call w.FileOperationCopy(pluginsFolder, destPluginsFolder, w.FileOperationNoErrorUI+w.FileOperationNoConfirmation)
end if
end if
#endif
#if TargetLinux
// please copy libs or put symlinks in the folder now
Break
#endif
End Sub
End Class
Class Session Inherits WebSession
Const ErrorDialogCancel = "Do Not Send"
Const ErrorDialogMessage = "This application has encountered an error and cannot continue."
Const ErrorDialogQuestion = "Please describe what you were doing right before the error occurred:"
Const ErrorDialogSubmit = "Send"
Const ErrorThankYou = "Thank You"
Const ErrorThankYouMessage = "Your feedback helps us make improvements."
Const NoJavascriptInstructions = "To turn Javascript on, please refer to your browser settings window."
Const NoJavascriptMessage = "Javascript must be enabled to access this page."
End Class
Class WebPage1 Inherits WebPage
Const kLibrary = "libvlc"
Control ImageViewer Inherits WebImageView
ControlInstance ImageViewer Inherits WebImageView
EventHandler Sub PictureChanged()
CheckNewFrame
End EventHandler
End Control
Control Info Inherits WebLabel
ControlInstance Info Inherits WebLabel
End Control
Control Label1 Inherits WebLabel
ControlInstance Label1 Inherits WebLabel
End Control
EventHandler Sub Close()
if mp<>Nil then
mp.stop
end if
End EventHandler
EventHandler Sub Open()
OpenFile
CheckNewFrame
End EventHandler
Sub CheckNewFrame()
// show frame counter
Counter = Counter + 1
info.text = Str(Counter)
if mp<>nil then
// and draw picture to window
CurrentPicture = mp.CopyPicture
if CurrentPicture<>nil then
ImageViewer.Picture = CurrentPicture
end if
end if
End Sub
Sub OpenFile()
dim moviefile as FolderItem = SpecialFolder.Desktop.Child("test.mov")
if moviefile.Exists = false then
MsgBox "Please put test.mov on your desktop or change path in code."
Return
end if
dim LibName as string = kLibrary
dim ExecutableFolder as FolderItem = app.ExecutableFile.parent
#if TargetMacOS then
// preload library, so it's not complaining that file is not found later.
dim LibFolder as FolderItem = ExecutableFolder.Child("lib")
dim libvlccore9 as FolderItem = LibFolder.Child("libvlccore.9.dylib")
if libvlccore9 <> nil and libvlccore9.Exists then
dim s as new SoftDeclareMBS
if s.LoadDylib(libvlccore9.NativePath) then
'MsgBox "OK"
System.DebugLog libvlccore9.name+" loaded."
else
MsgBox s.Liberror
end if
end if
dim libvlccore8 as FolderItem = LibFolder.Child("libvlccore.8.dylib")
if libvlccore8 <> nil and libvlccore8.Exists then
dim s as new SoftDeclareMBS
if s.LoadDylib(libvlccore8.NativePath) then
'MsgBox "OK"
System.DebugLog libvlccore8.name+" loaded."
else
MsgBox s.Liberror
end if
end if
dim libvlc5 as FolderItem = LibFolder.Child("libvlc.5.dylib")
if libvlc5 <> nil and libvlc5.Exists then
dim s as new SoftDeclareMBS
if s.LoadDylib(libvlc5.NativePath) then
'MsgBox "OK"
LibName = libvlc5.NativePath
System.DebugLog libvlc5.name+" loaded."
else
MsgBox s.Liberror
end if
end if
// we need to put path to plugins in environment variable to make it work
dim Plugins as FolderItem = ExecutableFolder.Child("plugins")
System.EnvironmentVariable("VLC_PLUGIN_PATH") = Plugins.NativePath
#endif
// load library
if VLCInstanceMBS.LoadLibrary(LibName) then
System.DebugLog "Library Loaded."
else
msgbox "Failed to load library"+EndOfLine+EndOfLine+VLCInstanceMBS.GetLoadError
Return
end if
// startup vlc engine
dim margs(-1) as string
margs.append "--no-video-title-show" // nor the filename displayed */
margs.append "--verbose=0" // show only errors */
margs.append "--no-media-library" // don't want that */
margs.append "--no-sub-autodetect" // don't want subtitles */
margs.append "--ignore-config"
// System.DebugLog "Init..."
dim v as new VLCInstanceMBS(margs)
// System.DebugLog "Inited."
if v.Handle=0 then
msgbox "Failed to initialise."
Return
end if
// and simply play a movie. Video goes to our buffer, so we can get it in the timer
#if RBVersion < 2013 then
m = VLCMediaMBS.MediaWithPath(v, Moviefile.UnixpathMBS)
#else
m = VLCMediaMBS.MediaWithPath(v, Moviefile.NativePath)
#endif
if m = nil then
MsgBox "Failed to get media."
Return
end if
mp = new VLCMediaPlayerMBS(m)
if mp.Handle=0 then
msgbox "Failed to init media player."
Return
end if
// figure out size of video
m.Parse
dim info() as VLCMediaTrackInfoMBS = m.TrackInfos
dim h as integer = 640
dim w as integer = 480
for each i as VLCMediaTrackInfoMBS in info
if i.Type = i.TrackVideo then
System.DebugLog "Video track with: "+str(i.Width)+" x "+str(i.Height)
w = i.Width
h = i.Height
end if
next
ImageViewer.Width = w
ImageViewer.Height = h
mp.VideoSetCallback w, h
call mp.Play
End Sub
Property Counter As Integer
Property CurrentPicture As Picture
Property m As VLCMediaMBS
Property mp As VLCMediaPlayerMBS
End Class
End Project
See also:
The items on this page are in the following plugins: MBS VLC Plugin.
Feedback: Report problem or ask question.