Hello and welcome to e health forum.
In the situation described you may have contacted with blood while at play, which might have dried up in about 2-5 minutes. Such blood does not retain the infectivity as viruses become inactivated outside the human body.
Hence the chances for infection while you were masturbating, would be very less likely.
There is no need to be worried about.
You might consult with a HIV counselor or a doctor for proper advice and counseling.