1. When I entered the room, he played the piano.

2. When I entered the room, he started to play the piano.

(Is #1 grammatical? Is #1 similar to #2?)

3. When I entered the room, he had been playing the piano for an hour.

4. When I entered the room, he was playing the piano.

(Are both grammatical?)

All 4 are grammatically correct.

The first two are close, but don't mean exactly the same thing. In #1, it isn't clear if he started playing when "I" entered or if he had already been playing and then he continued.

1. Yes, sentence #1 is grammatical. It uses the past simple tense to indicate an action that occurred when you entered the room.

2. Sentence #1 is similar to sentence #2 in the sense that both indicate that the person in the room started playing the piano when you entered. However, sentence #2 specifically emphasizes the beginning of the action by using the phrase "started to play."

3. Yes, both sentences #3 and #4 are grammatical.

Sentence #3 uses the past perfect continuous tense, which indicates that the person had been playing the piano continuously for an hour leading up to the point when you entered the room.

Sentence #4 uses the past continuous tense, which shows an ongoing action that was in progress when you entered the room.