I think it has to be direct sunlight. I'm guessing a window would be better than nothing, though. I put mine outside. I think even an open window would be better than through glass.
According to this, they are even starting to make washing machines that come with these little balls already installed.
https://household-tips.thefuntimesgu...laundry-balls/
https://www.youtube.com/watch?v=LYp8R_CuMl0