The minimal research I’ve done on this suggests that when iTunes is playing a movie in full screen mode, it has no formal window corresponding to the movie “ but it does if playing a movie in any other mode. There’ll be no separate window when playing a sound file either, so you’d also need to check for that. This might give you something to go on:
set movieExtensions to {"mov"} -- Add more movie file name extensions as required.
tell application "iTunes"
-- Get the name and file of the current track.
set {name:trackName, location:trackFile} to current track
-- Get the name extension of the file.
set fileExtension to name extension of (info for trackFile)
-- If the file name has a likely extension and there's no window corresponding to the track name, stick neck out.
if (fileExtension is in movieExtensions) and (name of windows does not contain trackName) then say "You are watching a movie in iTunes in Full Screen mode."
end tell
Nigel, there isn’t a separate window if the movie is playing inside the iTunes window. On a different note, you could try checking the kind of the file (not saying it would be any more reliable though).
tell application "iTunes"
tell current track's kind to it contains "video" or it contains "movie"
if (result) and (name of windows does not contain (current track's name)) then
-- You are watching a movie in iTunes in that is not in a separate window.
end if
end tell
Thanks for that. I didn’t understand what you were saying at first, as both the QuickTime movies I put into iTunes to research this query open in a separate window when they play “ unless they’re playing in Full Screen mode. But I see there’s a actually preference setting for this. Unless anyone comes up with a better idea, SpiralOcean may have to ensure that this preference is favourably set.
It’s very close, but I found a couple tweeks it needed.
If iTunes is not playing anything, an error pops up.
If the Movie has been played and then paused, the script will return true.
I was able to fix those two with the player state property.
This will work for what I need it to. However, when I change the prefence to ‘play videos in the main window’, then the script still returns true, even though it isn’t full screen. It’s not in a separate window, but it is in the now playing window. However, since I only watch movies in full screen, this will effectivly do what I need.
Again, thanks for the brilliant post!
tell application "Finder"
set activeApplication to get (name of every process whose frontmost is 1) as string
end tell
if activeApplication is "iTunes" then
tell application "iTunes"
if player state is not stopped then
tell current track's kind to it contains "video" or it contains "movie"
if (result) and (name of windows does not contain (current track's name)) and (player state is playing) then
return true
-- You are watching a movie in iTunes in that is not in a separate window.
else
return false
end if
end if
end tell
end if