Video URL

I’m trying to open a YouTube (or any video url link) on pressing a button and it doesn’t work.

Excuse me, I’m new to Xojo.

I have this button with this action line:

MoviePlayer1.Movie = Movie.OpenURL(“Hold Up- Neon Vines (Ableton Live Looping with Push 2, MPC One and LUMI) - YouTube”)
MoviePlayer1.Play

I have try by adding a Movie Player control on the canvas also put the Movie Player control inside an HTML Viewer and it doesn’t work. I find that there is a lack of documentation on this subject. Maybe I’m not looking in the right place.

Can you help me please. It’s supposed to be straightforward according to the documentation I found, but again, it’s not accurate. After 1:30 of trying, I have no choice but to ask for your help.

thanks for your help!

Movie.OpenURL accepts only movie files. I can tell from the forum trying to be helpful, that you’re linking to a YouTube page. This will not work. Note that YouTube makes it incredibly difficult for people to download the movie files directly.

If you’re using a YouTube video I would recommend a HTMLViewer and the embed code available from the YouTube video page (Click Share, then Embed).

Thanks Tim, but I have also tried a movie files from my host server.

I’m on Mac, could it be the problem?

Thanks,

Roger

It is working on Xojo v2020 r2.1 for Windows

I haven’t been able to reproduce your results here on macOS 10.14.6 with Xojo 2020r2.1.

MoviePlayerURL.xojo_xml_project

The test mp4 file I got by googling “test mp4 video” as the sample in the Xojo documentation was not available.

Are you perhaps loading the file via http and not https? macOS doesn’t really like this. There are workarounds, but Apple has a habit of breaking them… You’ll have to dig them up.

I do this in my app, and it’s been working perfectly for over a year. Of note, I am using an HTMLViewer, and not MoviePlayer

Two screens. One has a list of movies in a listbox. Select a movie and press the Play button. Note. My MovieCode is a string property, and this changes with the listbox.change. The MovieCode holds the YouTube ID you get from your YouTube channel. Here is an example of one of mine you can replace with my MovieCode property: rKmdHr8ruO4

Play button code:

VideoScreen.Show
VideoScreen.HTMLViewer1.LoadURL("https://www.youtube.com/embed/" + MovieCode + "?rel=0&autoplay=1")

The autoplay works on Mac, but I still have to click the play button on the HTMLViewer to play the movie on Windows

Second screen is simply a video screen with the HTMLViewer. Only fun thing I have with this is to maximize the screen in the Open event:

#If TargetMacOS Then
  Self.FullScreen = False
  Self.MenuBarVisible = True
  Self.Maximize
#else
  self.Maximize
#Endif

HTH!

Hey Ryan, thanks I will try that.
I have used the MoviePlayer control inside of the HTMLViewer, but it didn’t work out too.
I will study your code.
Big thanks!

Roger

Hum… Not sure how or where to add code

For the button code, there is no problem.

But what do you mean the second screen and where to put the code?
What the VideoScreen.Show for?
Sorry, I’m new into Xojo.

Roger

Hey, I finally found the solution and the cause of the problem for Movie.OpenURL for Mac users issue.

Look at these two examples:
MoviePlayer1.Movie = Movie.OpenURL (“https://www.link.com/movie1.mp4”)
MoviePlayer1.Play

MoviePlayer1.Movie = Movie.OpenURL (“http://www.link.com/movie1.mp4”)
MoviePlayer1.Play

Can you see the difference?

Yes? maybe no?

The problem with the Movie.OpenURL problem is the syntax of the URL.

If you put a (s) to the HTTPS - it is going to work!
But, if you don’t put the (s) after the HTTP, you will get the problem. The video won’t show up in the MoviePlay1.Play control even the movie loading up.

So, hope this help people with the same situation.

Thanks to all the reply and help from Tim and Ryan! You’re the best!

Roger :slight_smile:

VideoScreen is the name of my second window. All the code I have above is in the Play button of the first screen. This opens the second screen (VideoScreen), plays the movie, and maximizes the size. You would replace this with the name of your video window if you were using a second window to display the video, but it sounds like you discovered what you need with the MoviePlayer

On macOs you need to add an exemption to your plist requesting macos to allow that domain to be used unsecured. Otherwise macos only allows secure “https” connnections to you application.

You have to add this to your plist and drop the plist in the navigator.

Read more here:
https://docs.xojo.com/UserGuide:App_Transport_Security

Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.