Tool to achieve the easiest way of communication with the video/chat frames.
You should have the two iframes already created on the DOM with the the attributes name="video-frame"
and name="chat-frame"
respectively. The video-frame
needs the attribute allow="camera;microphone;autoplay;fullscreen"
in order to allow the user to activate his camera in private and his camera and microphone in VIP.
You can do this inyecting directly to window:
<script src="path/to/lib.js"></script>
<script src="path/to/your.js"></script>
Or if you're working with NPM / ES6:
npm install --save @pw2016/pw-player-communicator
...
import { Communicator } from "@pw2016/pw-player-communicator";
Maybe you are interested in the Integration examples.
If you are inyecting into window:
var communicator = new PWPlayer.Communicator({
sessionToken: sessionToken
});
Or if you're working with NPM / ES6:
const communicator = new Communicator({
sessionToken: "sessionToken"
});
communicator.on("videoPlay", function(){
console.log("video play in tester");
});
- videoPlay()
- videoStop()
- videoOffline()
- videoError()
- chatMessage(object: { nick, message })
- roomModeUpdate(string: roomMode)
- VIPRequestStatusUpdate(string: status)
- disconnected(string: reason)
- userCamStatus(string: status)
- setVolume(float 0 ... 1: volume)
- setMuted(boolean: muted)
- destroyVideo()
- activateUserCam()
- deactivateUserCam()
- playVideo()
-
sendMessage(string: message)
-
goToGroupChat()
-
requestVIP()
-
You have one example of the tester in the folder: examples/tester
Some browser doesn't allow autoplay with sound. You can fix this with AudioContext and adding the permission autoplay in the iframe
You have one example in the folder: examples/detectnoaudio
If you have the low power mode on in your iPhone, you can´t see the video because the phone is trying to keep the battery.
You can fix this with checking if you got the "videoPlay" event in the communicator after few seconds.
You have one example in the folder: examples/lowpowermodeiphone
Currently we have an example of integration using Next.js using the appRouter.
Check out the Next.js integration example.
New event to expose the user cam status:
- userCamStatus(string: status)
The next methods are no longer available. Sending tips or toys now should be done throug api request.
- sendTip(int: amount)
- sendToy(int: amount)