I’ve been working on this for a week now, and what I want to do is that my video player which has an ID of “stream” and my column name from db is also “stream”, the vid player will automatically play based on the value on the db table. this is a twitch API. here is the code for the player:
var options = {
width: 854,
height: 480,
layout: "video",
autoplay: false
};
var embed = new Twitch.Player("stream", options);
changeChannel = (chan) => {
embed.setChannel(chan);
}
and if needed to understand the function, this is the code for the editing the text field.
<input type ="text" name="stream" id="stream" class='form-control' value="{{$match->stream}}" style="width: 45%;"/>
<button id="editStreamBtn" type="button" onClick="changeChannel(document.getElementById('stream').value)" class="btn btn-success" data-edit-text="Update">Update</button>
upon editing and updating the video it works fine and it gets the right channel, until it refreshes the page, the text field is the same value as the updated one, but the stream player isn't working the same way. Any ideas why? TYIA
However in your source code you do have two elements with the id of “stream”. One is the div and one is the channel input field. So you fetch the channel name from the input and then try to update that input field to be an existing Twitch Player, which of course doesn’t work
Thanks for your reply Barry, but dang it. I really still don’t know how to qery it out. i’ve changed the player div id to “player” but it still doesn’t work, is there any way for it to become an interactive player barry? i really do need this functionality i just want the value of the div player to be the exact column db value which is $match->stream.
please help!
holy hell barry, you’re a life saver! thank you so much. I didn’t really know that the $match->stream syntax works on the js as well. arigato go saymas sensei!
I’m currently using php and laravel framework. but is there anyway for a js to have both youtube api and twitch api? since the site i’m currently working on is more on csgo dota and sports matches, which sports matches doesn’t have any streams in twitch. so i’m currently researching more into youtube api’s but I just don’t know if a single functionality will parse each api