Just Started!

Hello!

Sorry if I am posting in the wrong place. I’ve only been using Xojo for an couple hours and am relatively new to programming. (some scripting with BASH).

I managed to create the interface the way I wanted and in the folder where I placed the source files, I placed a file called video01.mp4. Eventually I’ll have 10 videos in there. But for now I am trying to keep it simple.

How do I play video01.mp4? I dropped a movieplayer object on there, but i don’t see in code how to point the movieplayer to the file on the file system. I would guess it would look like this, but not working. Can someone point me to a working example I can play with? The docs are not clicking for me (again, new to programming)

What I thin it should look like, but not sure.

movieplayer01.file = "./video01.mp4"
movieplayer01.play()

If you are new on Xojo, you should read the documentation. Here is an example from the manuals:

This example loads a movie called “MyMovie” from the current directory (folder) into MoviePlayer1 and plays it.
Dim f As FolderItem
f=GetFolderItem(“MyMovie”)
MoviePlayer1.Speaker=True
MoviePlayer1.HasStep=False
MoviePlayer1.movie=f.OpenAsMovie
MoviePlayer1.play

Put this in the Open event of your MoviePlayer instance:

Dim fi As FolderItem = SpecialFolder.Desktop.Child("Test.mp4") If Not fi.Exists Then // handle missing file End Me.Movie = fi.OpenAsMovie() Me.Play()
Remarks:

  • Read the docs about FolderItem to learn how to handle files in Xojo (FolderItem) and about SpecialFolder (SpecialFolder).

Also, you may find that the current directory/folder isn’t what you think it is when you’re debugging (Horst’s solution). You can avoid that by doing what Eli mentioned and putting it on your desktop so you know for sure what folder to go for [SpecialFolder.Desktop.Child(“Test.mp4”)].

Thanks for all the replies! It worked, my video started playing.

Still trying to get my head around the file path thing.

Yep, the file path thing threw me too, it can be a little confusing at first. It seems when running the file in the IDE, it looks for files in a different folder than when you run it as a compiled app. May I be the first to say this would be confusing for many a new user and should be addressed (I know, I should do the Feedback thing probably).

So true, but it’s because the builds use a special ‘debug’-folder to run in (IDE: edit - options - build settings to adjust this).

But I use different build settings for each program, so the Pros at Xojo Inc gave us the build settings in IDEs navigator. So you can copy files/folders to the right places for each target system or for all those. Just insert a new build setting via IDE menu and choose build step and copy files. Then drag the wanted files there to be copied before your app is started. This works best for me … and best of all: the original files (mostly database files here) wouldnt be touched by your debug code … just in case … :wink:

Thomas: Is there a way to just tell it to use the current folder that the app (or binary project file) launched from?

This is how to use compiler directives to avoid the options Configuration :slight_smile:

Dim applicationpath as FolderItem

'(See “pragma” to learn about compiler directives; using ‘#’)
#if not targetmacos and debugbuild then
applicationpath = GetFolderItem ("")
#else
applicationpath = GetFolderItem ("").Parent
#endif

'The above finds the EXE path and below we navigate into a folder called “movie folder” in the same path, and then select video1.mp4
'ApplicationPath.Child(“movie folder”).Child(“Video1.mp4”)

Yes, I currently use:

#if DebugBuild f = getFolderItem("").Parent.Child("svi.txt") #else f = getFolderItem("svi.txt") #endif

to find a file for loading for example. But is there some option I can set or a single snippet of code I can use in a module or something early on to tell Xojo “always look for any needed text or music or picture files in the current path”?

Unfortunately no. But if you are just beginning, at my site (http://www.xojodevspot.com) I have a single download software library that contains 400+ code snippets and reusable functions, a VB to Xojo converter, regex helper, sqlite db manager, networked and remote code library sharing, and a bunch of other tools all in one that you can also add to as you learn to easily store and retrieve code you reuse often. All code has search filters, screenshot ability, and searched for by entering a query. Even cooler, all the code used to make the entire Xojo Developer’s Library and tools is contained in the library! Custom controls, demos (with full source), and even web edition templates are included. :slight_smile: