Firsttime property: false
property times_scale1: 0
property times_scale2: 0
property latency: 0
property t_movies: ()
on run
Firsttime set to true
end run
on idle
if firsttime then
openFilms ()
else
tell application "QuickTime Player" to if exists then paper 2
tell t_movies
if not playing then of item 1 - 1 movie does not play
break item 2 - 2 film break
p set to 0
else
set p to 1
of if not playing then play item 2 item 2 - film 1 and film 2 is not playing -> play movie 2
end if
end tell
t_pos set to current time of documents - position players
The_diff set to (my milliieme ((item 1 of t_pos) / times_scale1)) - (my milliieme ((item 2 of t_pos) / times_scale2))
The_diff if> 0.1 or The_diff <-0.1 then - shifting more than a tenth of a second -> syncing
if p = 0 then - readers are paused
if times_scale2 = times_scale1 then
set current time of item 2 of t_movies to (current time of item 1 of t_movies)
else
set current time of item 2 of t_movies to ((current time of item 1 of t_movies) / times_scale1) * times_scale2
end if
else if p = 1 then - the players play
repeat with i from 1 to 10 - synchronizes during playback
set current time of item 2 of t_movies to (current time of item 1 of t_movies) + (Latency * i)
delay 3
t_pos set to current time of documents
The_diff set to (my milliieme ((item 1 of t_pos) / times_scale1)) - (my milliieme ((item 2 of t_pos) / times_scale2))
if The_diff <0.1 and The_diff> -0.1 then exit repeat - sync OK, less than a tenth of a second out of the loop
end repeat
end if
end if
end if
end if
return 5 - Check for 5 seconds
end idle
openFilms on ()
Film1 set to "/ Volumes / VolumeRaid / encoding / EXPO / MILES DAVIS/MOV/MilesDavisCS1.mov"
Film2 set to "/ Volumes / VolumeRaid / encoding / EXPO / DAVIS/MOV/MilesDavisCS1 MILES - copie.mov"
tell application "QuickTime Player"
close saving no documents
t_movies set to open Film1 (,) Film2
activate
tell Documents
repeat until load state of item 1 is complete and load state of item 2 is complete
delay 3
end repeat
set looping to true
1 item present scale screen display 2
2 present item scale screen display 1
break
times_scale1 set (,) to times_scale2 time scale
set current time to 0 - puts players at the beginning
play
delay 1
t_pos set to current time - position players
break
- Verify the diffferent time between the two films and adjusts the position of the second player according to the latency.
set n to (my milliieme ((item 1 of t_pos) / times_scale1)) - (my milliieme ((item 2 of t_pos) / times_scale2))
latency set to (n * times_scale2) div 1.3
set current time of item 1 to 0
set current time of item 2 to latency
delay 1
play
end tell
end tell
Firsttime set to false
end openFilms
we quit
Continuous quit
end quit
on milliieme (n) - returns the number with three decimal
return ((n * 1000) div 1) / 1000
end milliieme
Bookmarks