A US police officer played a Taylor Swift song on his phone in a bid to prevent activists who were filming him from uploading the video to YouTube.

The video platform regularly removes videos that break music copyright rules.

However, the officer's efforts were in vain as the clip of the encounter in Oakland, California promptly went viral.

Alameda County police told the BBC it was not "approved behavior".

The video was filmed by members of the Anti Police-Terror Project (APTP), which says it is a coalition that seeks to "eradicate police terror in communities of colour".

Some of them were protesting outside the courthouse at the pre-trial hearing of a San Leandro officer charged with the manslaughter of a black man.

In the video, the officer says: "You can record all you want, I just know it can't be posted to YouTube."

When asked if playing music in this way is a procedure, the officer responds: "It's not specifically outlined."

Later in the video, he confirms: "I'm playing music so that you can't post on YouTube."

The sheriff's department said: "We have seen the video and referred it to our internal affairs bureau. This is not approved behavior. It will not happen again."

The video, which was posted on 1 July, has had more than 180,000 views and remains online. It is also visible on the APTP's Twitter page.

BBC.