Player won't load source file by button script

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller

Post Reply
sritcp
Posts: 368
Joined: Tue Jun 05, 2012 5:38 pm
Location: Alexandria, Virginia

Player won't load source file by button script

Post by sritcp » Sat Jun 15, 2019 2:51 am

1. Drag a player object onto the card (hide it to begin with)
2. Create a button "PlayMovie" with the script:

Code: Select all

on mouseUp
   set the filename of player 1 of this card to the desktop folder & "/myVideo.mp4"
   set the currentTime of player 1 of this card to 0
   set the layer of player 1 of this card to top
   show player 1
   start player 1 
end mouseUp
3. Click on button "PlayMovie"; the player shows but with no file loaded. Check by typing into msg
put the filename of player 1 of this card
and it returns the correct file name
4. Type in message box
set the filename of player 1 of this card to the desktop folder & "/myVideo.mp4"
Now it loads!
5. Type in message box
start player 1
It plays!

Why won't it load from the button script? (Interestingly, after clicking the button, if I go to my Finder window and click once on my video file, it loads!)
LC 9.0.2, Mac 10.14.4

Thanks,
Sri

Klaus
Posts: 11011
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Player won't load source file by button script

Post by Klaus » Sat Jun 15, 2019 9:04 am

Hi Sri,

try with parens, which should ALWAYS be used when concatenating file- and objectnames!
And you can really leave out "... of this card...", lazy LC won't look anywhere else. :D

Code: Select all

...
set the filename of player 1 to (the desktop folder & "/myVideo.mp4")
...
## or maybe:
set the filename of player 1 to (specialfolderpath("desktop) & "/myVideo.mp4")
...
## And also worth a try:
put specialfolderpath("desktop) & "/myVideo.mp4" into tVideoFile
set the filename of player 1 to tVideoFile
...
If all of these don't work, you may have found another player bug. :?

Best

Klaus

Klaus
Posts: 11011
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Player won't load source file by button script

Post by Klaus » Sat Jun 15, 2019 10:55 am

I just tried:

Code: Select all

...
put "/Users/klaus2/Filme von Michael/a fine video.mp4" into tFile
set the filename of player 1 to tFile
...
and it worked as exspected in LC 9.0.4 on macOS 10.14.5

sritcp
Posts: 368
Joined: Tue Jun 05, 2012 5:38 pm
Location: Alexandria, Virginia

Re: Player won't load source file by button script

Post by sritcp » Sat Jun 15, 2019 2:31 pm

Hi Klaus:

I am not getting the same result!

By the way, to avoid the parenthesis issue, I tried

Code: Select all

set the filename of player 1 of this card to "/Users/Sri/Desktop/myVideo.mp4"
I also tried to put the file path string into a temp variable first. None of these works. The player shows, but is an empty and hollow frame. When I check if the filename has been set (put the filename of .....), yes, it has been.

Of course, everything works when I type it into msg.
Also, the button script works if I go to finder and click once on the video file name. The player immediately loads.

I am starting to think it is an OS issue with Mac 10.14.4

Regards,
Sri

sritcp
Posts: 368
Joined: Tue Jun 05, 2012 5:38 pm
Location: Alexandria, Virginia

Re: Player won't load source file by button script

Post by sritcp » Sat Jun 15, 2019 3:38 pm

I think I have figured it out. The culprit is

Code: Select all

set the layer of player 1 to top
in my original code. If you delete it, it works. If you add it, it doesn't. Something about changing the layer of the player after setting the filename or before "showing" it, I don't know.

Regards,
Sri.

sritcp
Posts: 368
Joined: Tue Jun 05, 2012 5:38 pm
Location: Alexandria, Virginia

Re: Player won't load source file by button script

Post by sritcp » Sat Jun 15, 2019 3:47 pm

The problem occurs if you set the layer AFTER you have set the filename.
Set the layer first, it works!

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”