I am building a chrome extension that plays a youtube video in the background page with controls for it in an injected content script. I can use play/pause quite effectively using this code:
iframe.contentWindow.postMessage(JSON.stringify({ "event": "command", "func": func, "args": args || [], "id": frame_id }), "*");
My question is how would I receive a response if I were to pass in say getVolume or something similar as my function? Incidentally, is there a better way to do this? Basically I wish for a video to be played in my extension. I could put the video in my content script but then every time a user changes/refreshes a page, the iframe for the video would also be refreshed. Is there a way to display a video in a content script that doesn't refresh with pages or do I have to do it an app?
Thanks in advance, Rohan