package host

import (
	"context"
	"encoding/json"
)

func (c Core) Play(ctx context.Context, in *PlayInput) (*PlayOutput, error) {
	marshal, err := json.Marshal(in)
	if err != nil {
		return nil, err
	}
	result, err := c.Plugin.CallHost("play", marshal)

	if err != nil {
		return nil, err
	}

	out := PlayOutput{}
	if err = json.Unmarshal(result, &out); err != nil {
		return nil, err
	}
	return &out, nil
}
