The time travel music and piano only opens a 20-year back and forth time crack, and the time of 1979 and 1999 is in strict sync,which means, if someone time travels from 1979 Jan 18, he can only get to 1999 Jan 18, exactly same time. Which explains why Xiao Yu is so sad when she heard the building is going to be destroyed on the day of graduation. If she could play into any time she likes,she could always return to the time before the building's gone and meet Lun.
There is a theory about two parallel universes existing when people time travel. And this film followed that theory up to 99%. When Lun asks to get into Xiao yu's house for the first time, he got rejected cause her mother said she's sick and resting. There is a POV shot from the upstairs window behind the curtain, which suggersts that someone is watching Lun. Who could that be? It must be the mid-aged Xiaoyu. Because at that time 20 years back, Xiao Yu's not dead yet, thus the present time Xiaoyu exists. Then in the end, when she dies in 1979, Lun of present time gets into her house, the music is still playing but Xiao yu disappeared. It is because the 1979 Xiao Yu's dead, and the present Xiao yu can no longer exist. In case of her mother's confusing behaviour, I don't think its her mental condition. It is because of the two universes , when something new happens 20 years ago, which changes present time, and changes the mother's memory simultaneously.
The bug of this theory is that if the time of 1979 and 1999 has to be preciously in sync, then how could Lun play back to the time before Xiaoyu finds the secret in 1979? He should get back on the night of the 1979's graduation day, at which time Xiao yu's already dead. I heard rumour says Jay Chou wanted a tragic ending, but the editor didn't agree, and the film is ended with Lun saving Xiaoyu .
But we can still try to explain the theory. Let us suppose the time crack repeats itself endlessly, and each run is from a certain time prior to xiaoyu's dicovery of the secret, say it starts on 1979 Jan 1, and ends on 1979 graduation day mid night. So when Lun played the music at the end of the film, he hits the last key when it turns mid night. As the result, he is ported to the begining of another round of time travel and arrives at 1979 Jan 1. At that time Xiaoyu hasn't found out about the secret, and doesn't know Lun at all. In case of why everyone could see lun and not just Xiaoyu, I think it is because the 1999 building is destroyed and he is stuck in 1979.
The last question is why he travels from 1999night time to 1979 day time if the time has to be in sync? Let's say the time crack starts at 1979 some day's day time. Or he just got knocked out by the steel ball and wakes up a few hours later...haha
I know this theory is not perfect, but I think it's the best you can find to justify the time travel mess in this film.
Source:
http://www.imdb.com/title/tt1037850/...t/82873067?p=2