Unfortunately, the prompt you provided is incomplete and lacks context. To answer your question, I need more information about what your friend did when they came in and interrupted you. Please provide the missing information so I can understand the situation and give you a proper response.
For example, you could complete the sentence with your friend's action:
By the time my friend called me, I had been watching TV for an hour.
By the time my friend arrived home, I had been watching TV for an hour.
By the time my friend sat down next to me, I had been watching TV for an hour.
The more details you provide, the better I can understand the context and give you a relevant and helpful answer.