Script: A Slideshow With Titles and Locations and Date in Photos

by: 
Last modified: Feb 11, 2020 8:48 AM
6 2072 Last modified Feb 11, 2020 8:48 AM

To be used in Photos 2.0 and 3.0 - it does not work in Photos 4.0 on Mojave.

Photos does not yet support slideshows with text annotations well. It is easy to create a slideshow to show the photos, but if we want to show annotations, like titles, the dates, or the location, we have to add a title slide for each photo and copy and paste the metadata manually from the info panel into the title slide, a lot of tedious work.Or, we can create a duplicate of each photo and write the text directly into the duplicate photo using the Markup extension and use the annotated duplicates for the slideshow. But this will blow up the library size.We have to do it over and over again, each time we update the slideshow. In iPhoto or Aperture we could add the metadata automatically to show them with the photos during a slideshow, which has been much more convenient..

I experimented a bit, to make this automatic in Photos as well. One way would be to use an Apple Script, and display an info panel, whenever a new photo is shown. But this is difficult, because Apple Script cannot access a running slideshow and check, which photo is currently shown.I opted for a solution, where the script is stepping an instant slideshow individually and andvances the slideshow manually, after displaying the information.This script will start a slideshow, pause it immediately, display a notification banner, wait a few seconds, then start the slideshow again. The solution with the notifications does not work, if the script is compiled as an application.Does anyone know, how to allow a compiled script to display notifications as banners in the Notification Center?

The user will have to select all photos for the slideshow in photos, then start the script to show an instant slideshow. The script has a variable "Shuffle". If this variable is set to true, the slideshow will be random, otherwise in the order the photos have been selected. I would silence the sound, or it will be no fun, because the sound will continually stop, when the slideshow is paused.

The running slideshow will look like this, with the notifications popping up in the upper right corner of the screen:

You will also see the history, if you open the Notification Center as "Script Editor" messages, if you missed a caption. And the current caption will be saved to the clipboard. In addition to "Do not disturb" I'm keeping Night Shift disabled, so the colors will be displayed naturally and not shifted towards warmer colors.


-- copy the script from here -- ✄ -- ✄ -- ✄ -- ✄--

-- This script will play the currently selected items as a slideshow and shuffle the items for random results
-- The Moments name, the title, and the filename will be displayed in the notification center
-- To be able to see the notifications, enable "System Preferences > Notifications" for Script Editor.
-- Set the style to "Banners" and disable "Do not disturb" in the Notification center.
-- Run this script directly from Script Editor using the Run button and stop it using the stop button. 
-- Push the script editor window to the border of the display or ssign it to a different desktop than photos.
-- When I save the script as an application and run the application, the notifications do not show in the notification center

-- Before you run the script, select the photos on Photos that you want to use as the slideshow
-- If you do not want to shuffle the photos, set the variable "Shuffle" to false
-- The variable showslide_duration controls the duration, how long a slide is shown

-- test with small selecctions of photos, if you want to shuffle the slides.  The shuffling takes a long time for a large set of photos.




on getCurrentSelection()
	tell application "Photos"
		set imageSel to {}
		try
			set imageSel to (get selection)
		on error errTexttwo number errNumtwo
			display dialog "Cannot get the selection: " & errNumtwo & return & errTexttwo
		end try
		return imageSel
	end tell
end getCurrentSelection


set Shuffle to true -- set this to false, if you do not want to shuffel the photos randomly
set showslide_duration to 3 --- show each slide for three seconds

set thephotos to getCurrentSelection()

repeat 10 times
	
	tell application "Photos"
		set nitems to (count of thephotos)
		
		if Shuffle then -- shuffle the slide if Shuffle is true
			repeat 3 times --shuffle three times for more randomness
				if (nitems > 1) then
					repeat nitems times --shuffle the photos in the list
						set split to random number (nitems - 2) + 1
						
						if (split < 1) then
							set split to 1
						end if
						
						if split is 1 then
							set head to {}
							set tail to items 2 thru nitems of thephotos
						end if
						
						if split is nitems then
							set head to items 1 thru (nitems - 1) of thephotos
							set tail to {}
						end if
						
						if (split > 1) and (split < nitems) then
							set head to items 1 thru (split - 1) of thephotos as list
							set tail to items (split + 1) thru nitems of thephotos as list
						end if
						set thephotos to head & tail & (item split of thephotos as list)
					end repeat
				end if
			end repeat
		end if -- Shuffle
		
		
		
		start slideshow using thephotos as list
		repeat with im in thephotos
			pause slideshow
			set nTitle to " "
			set ndesc to " "
			
			tell im
				try -- get the title of the photo
					set nTitle to its name as string
					if nTitle is equal to "missing value" then
						set nTitle to " "
					end if
				end try
				
				set nDate to its date as string -- get the date				
				set nFname to its filename as string --get the filename
				try
					set ndesc to its description as string -- get the description
					if ndesc is equal to "missing value" then
						set ndesc to " "
					end if
				end try
			end tell
			set theMoments to {nDate} -- default, only the date, if the moment cannot be retrieved			
			try
				set thisId to id of im
				set theMoments to the name of (moments whose id of media items contains thisId)
			end try
			
			
			display notification ndesc with title (nTitle & " " & nFname) subtitle (item 1 of theMoments)
			set the clipboard to (nFname & " " & nTitle & " " & (item 1 of theMoments))
			
			delay showslide_duration
			
			resume slideshow
			next slide
		end repeat
		stop slideshow
		
	end tell
end repeat

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.