Media playback is unsupported on your device Media caption Watch police arrest two black men at Starbucks - and the protests that followed

Coffee chain Starbucks is to close more than 8,000 company-owned branches in the US for an afternoon next month to carry out "racial bias" training.

The aim is to prevent discrimination in Starbucks stores.

The move comes after the firm had to apologise over last week's arrest of two black men who were waiting to meet someone in a Starbucks in Philadelphia.

Following the incident, protesters converged on the store and there were calls for a boycott of Starbucks.

Starbucks' chief executive Kevin Johnson said he had been "learning what we did wrong and the steps we need to take to fix it".

Mr Johnson said he had spent the last few days in Philadelphia. He has also met the two men who were arrested.

In a joint statement, the men's lawyer and Starbucks said their discussions had been "constructive".

Mr Johnson had apologised on behalf of the company and the conversation was continuing about how this "painful incident can become a vehicle for positive social change", the statement added.

All Starbucks company-owned branches and corporate offices will be closed on the afternoon of Tuesday 29 May.

Nearly 175,000 staff will receive the training, as will all future recruits.

The closure could cost an estimated $20m in lost sales.

Days after the coffee company was forced to apologise to the Philadelphia men, footage emerged of an apparent race-related incident in a Starbucks store in California.

Brandon Ward, a black Starbucks customer in Torrance in southern California, posted a video on social media purporting to show an incident in January, in which he was barred from using a toilet - despite being a paying customer - while a white man who hadn't bought anything was allowed to use the facilities.

Media playback is unsupported on your device Media caption Brandon Ward's video of his encounter at a Starbucks has gone viral

Mr Ward's video provoked a strong reaction on social media, with some criticising the coffee giant for its actions.

Others said they had undergone similar experiences to Mr Ward at the company's stores.

As part of its damage-limitation effort, the company has asked civil rights leaders and officials including former US Attorney General Eric Holder for help in developing a "curriculum" for staff, which it will make available to other companies.

The training will "address implicit bias, promote conscious inclusion, prevent discrimination and ensure everyone inside a Starbucks store feels safe and welcome", the company statement said.

"Closing our stores for racial bias training is just one step in a journey that requires dedication from every level of our company and partnerships in our local communities," said Mr Johnson.

In last Thursday's incident, two black men were waiting in a Philadelphia Starbucks to meet someone and had not bought anything when the store manager called police.

Amateur video showed police placing the pair, who were accused by shop staff of trespassing, in handcuffs.

"All the other white people are wondering why it's never happened to us when we do the same thing," tweeted customer Melissa DePino, who posted a video of the incident.

Mr Johnson said the video was "hard to watch" and that the actions taken were "wrong" and "reprehensible".

In an interview on Monday, Mr Johnson said the Philadelphia branch manager who called police about the two men had now left the company.

'Race Together'

In 2015 a Starbucks public relations campaign to encourage customers to discuss issues of race backfired, when the company's big roll-out was widely mocked.

Launching the "Race Together" campaign, Starbucks had said it wanted to engage customers in a conversation about race amid protests about policing of African-American communities.

It involved baristas scribbling the words "Race Together" on cups and attempting to "engage customers in conversation through Race Together stickers available in select stores", Starbucks said.

But instead the hashtag #racetogether was hijacked on social media and the campaign became the subject of widespread criticism.