The Gemara in Masechet Shabbat (18a) addresses the case of a water-operated mill that one sets into motion before Shabbat so that it will operate and grind wheat throughout Shabbat. Bet Hillel (the school of the Sage Hillel) permitted such an arrangement, since all the activity is performed before Shabbat. The mechanism operates on Shabbat without any involvement on the part of the individual, and thus no Shabbat violation is entailed.
This view is codified by the Shulhan Aruch (Orah Haim 252:6), who adds that even if the mechanism makes a sound, it may nevertheless be allowed to operate on its own during Shabbat.
This Halacha is the basis for the widespread use of timers, or "Shabbat clocks," to turn on and off lights and appliances on Shabbat. Thus, for example, one may set a timer before Shabbat to turn on and off a light, an electric fan or heating system during Shabbat. Since the person's involvement occurs only before Shabbat, and not during Shabbat, the timer's operation on Shabbat does not entail any violation.
Hacham Ovadia Yosef, in his work Halichot Olam, extends this Halacha even to washing machines and dryers. It is permissible to put a load of laundry in the washer or dryer right before Shabbat and have the cycle run during the Shabbat. (It should be noted that Ashknezaim are generally more stringent in this regard.)
Though this may be obvious, we should emphasize that this Halacha does not extend to televisions. It is, of course, strictly forbidden to watch television on Shabbat (and even during the week the propriety of watching television is certainly questionable), even if one sets the television on a timer before Shabbat, as watching television is not at all in the spirit of the day. This applies as well to radios and music players. One may not set such devices on a timer before Shabbat to play music or radio stations on Shabbat. If a person normally sets his alarm clock to a radio station, he must turn the alarm off before Shabbat. It is permissible, however, to set an alarm before Shabbat if it just makes some kind of sound, rather than play a radio station.
Summary: One may set lights and appliances on timers before Shabbat so that they turn on and off during Shabbat; one may similarly run the washer or dryer before Shabbat and have the cycle continue during Shabbat. One may not, however, set a radio, music player or television on a timer to have the device turn on during Shabbat.