tonyassi commited on
Commit
83f6fc8
·
verified ·
1 Parent(s): caf9f96

Create index.html

Browse files
Files changed (1) hide show
  1. index.html +83 -0
index.html ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Icon Button Video Selector</title>
7
+ <style>
8
+ .icon-container {
9
+ display: flex;
10
+ justify-content: center;
11
+ margin-top: 20px;
12
+ }
13
+ .icon-button {
14
+ cursor: pointer;
15
+ border: none;
16
+ background: none;
17
+ padding: 10px;
18
+ }
19
+ .icon-button img {
20
+ width: 50px; /* Adjust the size as needed */
21
+ height: auto;
22
+ }
23
+ </style>
24
+ </head>
25
+ <body>
26
+ <div class="icon-container">
27
+ <button class="icon-button" onclick="showVideo('https://huggingface.co/spaces/tonyassi/g/resolve/main/lucy/video1.mov')">
28
+ <img src="https://huggingface.co/spaces/tonyassi/g/resolve/main/icon/fish.png" alt="Fish Icon">
29
+ </button>
30
+ <button class="icon-button" onclick="showVideo('https://huggingface.co/spaces/tonyassi/g/resolve/main/lucy/video2.mov')">
31
+ <img src="https://huggingface.co/spaces/tonyassi/g/resolve/main/icon/david.png" alt="David Icon">
32
+ </button>
33
+ </div>
34
+
35
+ <div id="videoContainer" style="margin-top: 20px; display: none;">
36
+ <video id="videoPlayer" width="600" controls loop>
37
+ <source id="videoSource" src="" type="video/mp4">
38
+ Your browser does not support the video tag.
39
+ </video>
40
+ </div>
41
+
42
+ <script>
43
+ function showVideo(videoUrl) {
44
+ const videoContainer = document.getElementById('videoContainer');
45
+ const videoPlayer = document.getElementById('videoPlayer');
46
+ const videoSource = document.getElementById('videoSource');
47
+
48
+ // Set the video source and load it
49
+ videoSource.src = videoUrl;
50
+ videoPlayer.load();
51
+
52
+ // Show the video container (if necessary)
53
+ videoContainer.style.display = 'block';
54
+
55
+ // Play the video and request fullscreen immediately
56
+ videoPlayer.play().then(() => {
57
+ if (videoPlayer.requestFullscreen) {
58
+ videoPlayer.requestFullscreen();
59
+ } else if (videoPlayer.webkitRequestFullscreen) { // For Safari
60
+ videoPlayer.webkitRequestFullscreen();
61
+ } else if (videoPlayer.mozRequestFullScreen) { // For Firefox
62
+ videoPlayer.mozRequestFullScreen();
63
+ } else if (videoPlayer.msRequestFullscreen) { // For IE/Edge
64
+ videoPlayer.msRequestFullscreen();
65
+ }
66
+ }).catch((error) => {
67
+ console.error("Error attempting to play video in fullscreen:", error);
68
+ });
69
+ }
70
+
71
+ // Add event listeners for focus and blur to detect fullscreen exit
72
+ const videoPlayer = document.getElementById('videoPlayer');
73
+ videoPlayer.addEventListener('webkitendfullscreen', hideVideoOnExit); // Specific to iOS Safari
74
+ videoPlayer.addEventListener('pause', hideVideoOnExit); // Additional fallback for mobile
75
+ videoPlayer.addEventListener('ended', hideVideoOnExit); // Hide when video ends (optional)
76
+
77
+ function hideVideoOnExit() {
78
+ const videoContainer = document.getElementById('videoContainer');
79
+ videoContainer.style.display = 'none'; // Hide the video container
80
+ }
81
+ </script>
82
+ </body>
83
+ </html>