A police officer played a Taylor Swift song from his phone while being filmed by protestors in a bid to stop them uploading the video online.

However, his efforts were to little avail as a clip from the situation has since gone viral, receiving more 600,000 views.

A police officer was present outside of a courthouse in Oakland, California when the situation occurred.

He could be heard playing Taylor Swift's "Blank Space" while speaking to members of the Anti Police-Terror Project (APTP) who were protesting outside the courthouse.

As per the BBC, the Anti Police-Terror Project says it is a coalition that seeks to "eradicate police terror in communities of colour".

They were present in protest of the pre-trial hearing of an officer charged with the manslaughter of a Black man.

While speaking with APTP members and being filmed by them, the officer plays music, claiming that they will not be able to post the video to YouTube for that reason - YouTube frequently removes videos that break music copyright laws.

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

He is then asked: "Is there an administrative regulation for this right now?" to which he answers: "Not that I know of. I'm just listening to music."

APTP shared the video on YouTube, which has received 614, 743 views at the time of writing.

"APTP policy director James Burch was at a hearing for the cop who murdered Steven Taylor, when a sheriff deputy started to hassle him and others about where they placed a banner," the video's caption reads. "In the middle of their conversation, the deputy took out his phone and started playing Taylor Swift music. He openly admitted that he did this because he knows the video recording of the interaction would get taken down from YouTube. We'd heard about this phenomenon but now we have it on video."

A statement about the video has since been issued by Alameda County Sheriff's Department to BBC News in which they insisted that his behaviour was not "approved."

"We have seen the video and referred it to our internal affairs bureau. This is not approved behaviour. It will not happen again," the statement said.