How to set custme dimension and metric

You have to have a developer to create a listener to calculate the play duration value for you and then pass to the code you have here. You could also pass it in as in integer into an event value instead.