video player stops playing videos in list

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: FourthWorld, heatherlaine, Klaus, kevinmiller

xyz
Posts: 30
Joined: Sat Feb 29, 2020 4:45 am

video player stops playing videos in list

Post by xyz » Sun Apr 05, 2020 1:19 am

I thought it would be fun to create a program that will load each "Business Academy" video in turn and play it in a player. (That way I can watch them while also exercising!)

Each video is stored in a folder with the name "Lesson 1", "Lesson 2", etc. Each video that I want to show is similarly named (the "forum" made me remove the name of the files because it considers them "external links").

I start on video #1 by setting the filename property of the player to the full pathname of the first video.

When the "playStopped" message is sent, I "construct" a new complete file path name, set the filename property of the player to that new value, and then start the player again. I've checked multiple times - the newly constructed file name is correct (and it works for several files before it stops working).

When I begin with video #1 it plays until the end of #3 and then stops. When my program attempts to play video #4, the video player "goes blank" as if there is an invalid file name. But the full file name path is correct and the folder and video file are correctly named (both in my program and on my system).

I'm on Mac OS X 10_14. I tried escaping the space in the file name (a common practice on Mac's) with "\ ", but that made no difference.

I tried putting in a "wait 1 second" in case the player was "falling behind". That did not help.

I am baffled. Why does it stop loading/playing the video files?

Xero
Posts: 152
Joined: Sat Jun 23, 2018 2:22 pm

Re: video player stops playing videos in list

Post by Xero » Sun Apr 05, 2020 7:15 am

Would need more information, but from what experience I have...
1. Are all of the videos the same format? i.e. *.mov files?
I have had issues with some video formats in the past, and have had to convert them to file types that I know work. If the files are all from the same place/ business, it's highly unlikely this is the case.
2. There actually is an issue with the file and path name somehow. Remember that it needs to be exact, not a long hyphen as opposed to a short hyphen, all spaces where they need to be etc. Even something that looks OK may actually not be perfect.
3. There's some other issue that is as yet unknown due to code or method.
Are you making file names automatically (i.e. add 1 to the number at the end of the filename) and if so, is the filename going astray in that loop? Are you changing folders when you need to etc.

Have you tried starting your filenaming code so that it starts at 3 rather than 1? See if it's just a matter of the program not coping with more than 3 files? If so, it will play 3, 4, 5 and fall out at 6 or the like...
Outside of that, I guess we'd need to see what you have written to do the action that is going wrong. Can you post some of the code with file names etc redacted/ removed so we can see what's happening?
X

xyz
Posts: 30
Joined: Sat Feb 29, 2020 4:45 am

Re: video player stops playing videos in list

Post by xyz » Sun Apr 05, 2020 3:34 pm

Thanks for the response, Xero.

(1) Yes, all of the videos are of the same format, *.mp4.

(2) All of the file and folder names appear to be correct. I suppose there might be some kind of "unicode" thing going on that makes them look the same when they are actually different. :(

I tried to post images and code but the forum keeps telling me to remove this, that and the other thing. :( :( :(

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

Re: video player stops playing videos in list

Post by Klaus » Sun Apr 05, 2020 3:39 pm

Please tell us how you script the filenames/show us your script(s)!
I suspect this is a pathname issue.

Is this a standalone or does this also happen in the IDE? If runtime, how do you add your movies to the runtime?
Via the "Copy files" tab in the "Standalone Application Settings"? Then you will find them in -> specialfolderpath("resources")
in your runtime on ANY platform.

And you can check if somethings is going on:

Code: Select all

...
set the filename of player "xyz" to your_variable

## THE RESULT will be empty on success but may give a hint if not!
if the result <> EMPTY then
  answer "Problem:" && the result
end if
...

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: video player stops playing videos in list

Post by bogs » Sun Apr 05, 2020 3:39 pm

Above where you type in your reply, there is a button that says 'code display'. Just copy your code from the editor, and paste it inside of the code block.
Image

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7237
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: video player stops playing videos in list

Post by jacque » Sun Apr 05, 2020 5:59 pm

Sometimes setting the player filename to empty before changing it helps.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

xyz
Posts: 30
Joined: Sat Feb 29, 2020 4:45 am

Re: video player stops playing videos in list

Post by xyz » Sun Apr 05, 2020 7:52 pm

OK. The "code blocks" solved the posting problem. Thanks!

Edit: I run this in the IDE. I have not created a stand alone.

Edit: I inserted Klaus' suggested debugging code. The answer dialog reported a problem:
Problem: could not create movie reference.
I put a starting video number in a text box (field "fStart") then click the start button.

Code to start the process

Code: Select all

on mouseUp
   -- on startup, put in a default location for the source filename
   --  then replace the folder and file names as needed
   
   set the filename of player "player" to \
         "/Users/xyz/Downloads/LiveCode/Tutorials/Business Academy/Lesson 1/Lesson_1.mp4"
   
   put constructPathForNextVideo(field "fStart") into thePath
   set the filename of player "player" to thePath
   --replace " " with "\ " in thePath --> this did not help
   --wait 1 second --> this did not help
   start player "player"
   
   -- plays the following videos; does not play the others
   --   1-3, 6, 8, 9, 11-12 (stops on 13; I did not check the rest)
end mouseUp
Code to create name of next file

Code: Select all

function constructPathForNextVideo pStartNum
   -- check for valid file number
   --   add 1 to number if we are restarting on next video
   if pStartNum is empty then
      -- pStartNumber will be empty if this function was called from "playStopped"
      add 1 to field "fStart"
      put field "fStart" into pStartNum
      put pStartNum into field "fStart"
   end if
   if pStartNum < 1 or pStartNum > 60 then
      put 1 into field "fStart"
      put 1 into pStartNum
   end if
   
   -- create the folder name and file name
   put "Lesson " & pStartNum into nextFolder
   put "Lesson_" & pstartNum & ".mp4" into nextFile
   
   -- get the current "source" filename of the player so I can substitute in new values
   get the filename of player "player"
   put it into thePath
   set the filename of player "player" to empty --> per suggestion by jacque - did not solve the problem
   set the itemDelimiter to "/"
   put nextFolder into item 8 of thePath -- folder name
   put nextFile into item 9 of thePath -- file name

   return thePath
end constructPathForNextVideo
Code to run when each video has finished:

Code: Select all

on playStopped
   -- video finished; start the next one
   put constructPathForNextVideo() into thePath
   set the filename of player "player" to thePath
   start player "player"
end playStopped

SparkOut
Posts: 2852
Joined: Sun Sep 23, 2007 4:58 pm

Re: video player stops playing videos in list

Post by SparkOut » Sun Apr 05, 2020 8:40 pm

As Klaus said, this is likely to be a path issue, and from what I can see above, there doesn't seem to be any other indication that it is something else. No guarantee, but I really suspect that if you try

Code: Select all

on playStopped -- video finished; start the next one
   put constructPathForNextVideo() into thePath
   if there is a file thePath then
      set the filename of player "player" to thePath
      start player "player" 
   else
      answer "The filename" && thePath && "could not be found"
   end if
end playStopped
then you will probably get a clue about what in the filename is causing the problem. If you also add some more detail to the error message construct advised by Klaus to return the problem alert and the result and the filename being sought, you'll also get more idea about tracking down what is wrong with those problem files.

xyz
Posts: 30
Joined: Sat Feb 29, 2020 4:45 am

Re: video player stops playing videos in list

Post by xyz » Sun Apr 05, 2020 9:22 pm

Thanks for all of the replies.

Yes, putting in the debug code suggested, I am told that some of the files cannot be found. But, the fully qualified paths are correct and the files are, in fact, where they are supposed to be and they are individually playable outside of LC.

I'm back to thinking it might have something to do with the embedded spaces in the path (though escaping them does not solve the problem). Otherwise, I suppose it might be some kind of character encoding issue. (It's not a permissions issue - all of the permissions on all of the files & folders are the same).

:? :? :?

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: video player stops playing videos in list

Post by bogs » Sun Apr 05, 2020 10:50 pm

Just out of curiousity, what would happen if you say, moved all of the files you are playing to the documents folder (and altered the path accordingly) as a test?

If you already have them there, then you don't have to move them again, as I say, it is just curiousity on my part.
Image

xyz
Posts: 30
Joined: Sat Feb 29, 2020 4:45 am

Re: video player stops playing videos in list

Post by xyz » Mon Apr 06, 2020 12:40 am

Well, I already tried moving all of the files and their "parent folders" to the same directory that my livecode project is in:

/Users/xyz/Documents/My LiveCode/Projects/player_test/Lesson 1/Lesson_1.mp4

My project is in the player_test folder and the paths to the video files are: Lesson X/Lesson_X.mp4, etc.

Same problem. :cry:

Xero
Posts: 152
Joined: Sat Jun 23, 2018 2:22 pm

Re: video player stops playing videos in list

Post by Xero » Mon Apr 06, 2020 2:14 am

Just in case it is a filename/filepath issue, have you tried simplifying both of them?
As previously suggested, drop them into a folder that has a simpler path either:
1. Into the same folder as the player and use a relative pathname without all of the other subfolders, or;
2. In Documents folder or the like that is one folder only.
Then, take all of your files and rename them manually to be Lesson1.mp4, Lesson2.mp4, etc. and have them all sequentially, with no special characters, etc. all things you have manually controlled.
Also consider your code reading

Code: Select all

   -- create the folder name and file name
   put "Lesson" & space & pStartNum into nextFolder --remove space from within quotes and manually put it in. You may be "collecting spaces" as you code.
   put "Lesson_" & pstartNum & ".mp4" into nextFile
I'd also suggest that rather than putting a number into a field and adding 1 to it then putting it into a variable, you should (eventually) be able to just use the variable. If I were writing it, I would use the variable to track numbers etc. and then report that variable to a field for visual feedback on screen (i.e.)
Your code:

Code: Select all

function constructPathForNextVideo pStartNum
   -- check for valid file number
   --   add 1 to number if we are restarting on next video
   if pStartNum is empty then
      -- pStartNumber will be empty if this function was called from "playStopped"
      add 1 to field "fStart"
      put field "fStart" into pStartNum
      put pStartNum into field "fStart"
   end if
could be turned into:

Code: Select all

function constructPathForNextVideo pStartNum
   -- check for valid file number
   --   add 1 to number if we are restarting on next video
   if pStartNum is empty then
      -- pStartNumber will be empty if this function was called from "playStopped"
      put 1 into pStartNum --will guarantee you get 1 in pStartNum--
      put pStartNum into field "fStart" --will report what pStartNum container on screen--
   end if

This way, no matter what happens to your field, you will still be able to use the numbers because they are in a variable that you create and control outside of what's on screen. You will just need to make sure that you are not calling the field in subsequent lines of code, but instead referring to the container pStartNum. This may also need to be a global if you are using it in different places. It also saves a line of code...
Maybe that could help?
Xero

xyz
Posts: 30
Joined: Sat Feb 29, 2020 4:45 am

Re: video player stops playing videos in list

Post by xyz » Mon Apr 06, 2020 3:39 am

Xero, I made the changes re field "fStart" that you suggested. I also used your suggestion of constructing the file name with "space" rather than " ". Neither seemed to make any difference. :(

But, your suggestion that I put all of the video files in the same folder as my project DID WORK. (I copied 10 of the files and it played them all.) That is not my preferred solution, but it is a solution. It means I need to copy 50 more files and I still don't know why the other code worked for some of the files but not all of them.

ODDLY, the debug code that tests whether "there is a file named ..." fires and reports that the file cannot be found. Then the player proceeds to play it!! :?

But, I do appreciate all of the assistance that everyone provided on this. I now have a working version that I will be able to use while I exercise!! :)

Xero
Posts: 152
Joined: Sat Jun 23, 2018 2:22 pm

Re: video player stops playing videos in list

Post by Xero » Mon Apr 06, 2020 4:12 am

At least we found something that worked.
Hone in on your code for the folder part and you''ll probably solve your problem.
Good luck!
X

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

Re: video player stops playing videos in list

Post by Klaus » Mon Apr 06, 2020 8:23 am

Well, some videos in the "Business Academy" are NOT named Lesson_X.mp4!

Lesson_19 (Drag and Drop to Import and Export) -> Drag drop.mp4
Lesson_20 (Custom Progress Bar) -> Progres Bar.mp4, note the typo!
8)

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”