Shares of cable providers and entertainment companies in the U.S. are suffering their worst stretch in nearly two years, as traditional players struggle to adapt to a shift toward streaming services.

Americans are ditching television subscriptions in favor of viewing movies and TV shows through online services. The move disrupts a delicate ecosystem of media companies sustaining themselves on subscription fees from pay-TV providers, and echoes Amazon.com Inc.’s upending of the brick-and-mortar retail landscape.

This development, along with disruptions related to major summer storms, has been pushing down stocks of major cable and broadcast companies.

In a sign of the diverging fortunes, Roku Inc., an early player in streaming television, priced its initial public offering late Wednesday. The IPO price valued the company at about $1.3 billion, according to a person familiar with the deal.

A group of 13 media companies in the S&P 500 have fallen 3.5% so far in September, on track for its steepest monthly decline since December 2015, while the S&P 500 has gained 1.4%.