twitch.tv api- how to get logo of the streamer who is offline - twitch

twitch tv - how to get logo of the streamer who is offline?
For instance I can get logo link of the streamer like this(works only if the streamer online):
$(document).ready(function(){
getChannel("OgamingSC2");
});
function getChannel(name){
$.getJSON("https://api.twitch.tv/kraken/streams/"+name+"?callback=?",
operateResults);
}
function operateResults(data){
console.log(data.stream.channel.logo)//logo
}
But if the streamer offline:
data.stream
will be equal to null.
So how can I get the logo if the streamer offline?

Correct, stream will be null if the stream is offline. You can use the channels endpoint to get the logo of the broadcaster.

Related

Stream static video file through webrtc

what I am trying to accomplish is to have on my page audio and video file. And then send them through webrtc. I managed to do this with audio using web audio api like this.
HTML:
<audio id="audio">
<source src="../assets/outfoxing.mp3" />
</audio>
JS:
const audioElement = document.getElementById("audio");
const incomingSource = audioContext.createMediaElementSource(audioElement);
const outgoingStream = audioContext.createMediaStreamDestination();
incomingSource.connect(outgoingStream);
const outgoingTrack = outgoingStream.stream.getAudioTracks()[0];
audioElement.play();
await this.sendTransport.produce({ track: outgoingTrack });
For webrtc I am using mediasoup
Now I want to do the same with the video. But there is no such thing like web video api so I am stuck. How can I accomplish this task.
There are some limitations, but you could refer to this sample implementation.
It uses the captureStream() method.

Webrtc disable track doesn't turn off webcam

I am trying to implement a toggle video feature using webRTC. Refer to the following code:
<video id="remote" autoPlay></video>
<button onclick="toggleVideo()">Toggle video</button>
let localVideo = document.querySelector('#local');
const toggleVideo = () => {
localVideo.srcObject.getVideoTracks()[0].enabled = !localVideo.srcObject.getVideoTracks()[0].enabled
}
This turns off video as well as webcam indicator in firefox but not in chrome. Chrome only turns off the video.
According to MDN docs,
If the MediaStreamTrack represents the video input from a camera, disabling the track by setting enabled to false also updates device activity indicators to show that the camera is not currently recording or streaming. For example, the green "in use" light next to the camera in iMac and MacBook computers turns off while the track is muted in this way.
MDN docs
Is there any other workaround?

how to switch camera source in kurento?

I am trying to add an option of camera switch in video call handled by KMS (Kurento media server) and I am digging throw a lot to their documentation and other sources but I find nothing useful
var options = {
localVideo: videoInput,
remoteVideo: videoOutput,
onicecandidate: onIceCandidate,
mediaConstraints: {
audio: isAudio || call_settings.isAudio,
video: isVideo || call_settings.isVideo
}
}
webRtcPeer = kurentoUtils.WebRtcPeer.WebRtcPeerSendrecv(options, function (
this is my code which is connecting throw peer and all media permission is handled by kurento itself so that I am not able to change the source of media location.
and i am not sure how to do it with kurento any kind of help is appreciable thanks in advance
You can pass custom mediaConstraints to the options or create stream by yourself and send it as videoStream in the options and skip mediaConstraints as mentioned in kurento utils js docs.
For switching device / getting stream based on device, please refer below sample
https://webrtc.github.io/samples/src/content/devices/input-output/
You can refer below doc for videoStream usage
https://doc-kurento.readthedocs.io/en/stable/features/kurento_utils_js.html

Can I receive video without giving permission to browser to use my camera in SimpleWebRTC?

Does SimpleWebRTC has this feature to get data(video/audio) without giving permission to browser to use my camera/microphone?
// create our webrtc connection
var webrtc = new SimpleWebRTC({
// the id/element dom element that will hold "our" video
localVideoEl: 'localVideo',
// the id/element dom element that will hold remote videos
remoteVideosEl: '',
// immediately ask for camera access
**autoRequestMedia: true,**
debug: true,
detectSpeakingEvents: true,
autoAdjustMic: false,
media: {
video: false,
**audio: true**
},
});
When I change those parts surrounded by asterisks to true it works, otherwise it doesn't.
Have you tried setting autoRequestMedia to true and while having both video and audio of the media object set to false? You should receive the readyToCall event and can join the room as shown on the simplewebrtc homepage.
First negotiate (accept the call/join the room) with video and audio and then disable the video, somehting like webrtc.videoStreams.disable()

Chaining html5 videos with Video.Js

I am looking fore some code allowing me to launch automatically a video after another one.
I'am using the great video.js library, which has a quite complete API. I found some snippet to get an event listener working at the end of the 1st video, but then I cannot launch the second one.
This is working, displaying an alert at the end of the 1st video :
_V_("intro").ready(function(){
this.addEvent("ended", function(){
alert('foo');
});
});
And this is also working, launching a video in fullscreen on page reload :
_V_("leader").ready(function(){
var leader = this;
leader.requestFullScreen();
leader.play();
});
But I can't get the 2nd video launching in fullscreen at the end of 1st video...
Last subtility, I would like to entirely build the 2nd video with javascript, not having to write it and just hiding id with CSS.
Thank you folks !
Elliot
You can simply use the provided 'src' method in the Video.js API, if you want to play a second video right after the first one finishes it would work like this:
_V_("intro").ready(function(){
this.addEvent("ended", function(){
this.src({ type: "video/mp4", src: "http://path/to/second/video.mp4" });
});
});