File size: 6,341 Bytes
5dbe9dd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
628c548
 
 
 
 
5dbe9dd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
628c548
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5dbe9dd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
628c548
 
 
 
 
 
 
 
5dbe9dd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
195ccc7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>MPEG Looper</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
    <script src="https://unpkg.com/feather-icons"></script>
    <style>
        body {
            background-color: #1a1a2e;
            color: #e6e6e6;
            height: 100vh;
            overflow: hidden;
        }
        .video-container {
            position: relative;
            width: 100%;
            height: 100%;
        }
        video {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            object-fit: contain;
        }
        .controls {
            position: absolute;
            bottom: 20px;
            left: 50%;
            transform: translateX(-50%);
            background: rgba(0,0,0,0.7);
            padding: 10px 20px;
            border-radius: 20px;
            display: flex;
            gap: 15px;
            align-items: center;
            z-index: 10;
            transition: opacity 0.3s ease;
        }
        .controls.hidden {
            opacity: 0;
            pointer-events: none;
        }
        .file-input {
            display: none;
        }
        .btn {
            background: #4a4a8a;
            color: white;
            border: none;
            padding: 8px 16px;
            border-radius: 20px;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 8px;
            transition: all 0.3s ease;
        }
        .btn:hover {
            background: #6a6aaa;
        }
        .status {
            font-size: 14px;
            color: #aaa;
        }
        .fullscreen {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: 5;
        }
    </style>
</head>
<body class="font-sans">
    <div class="video-container">
        <video id="videoPlayer" loop></video>
        <div class="fullscreen" id="clickArea"></div>
        
        <div class="controls">
            <button id="selectFilesBtn" class="btn">
                <i data-feather="folder"></i>
                Select Files
            </button>
            <span id="status" class="status">No files selected</span>
            <input type="file" id="fileInput" class="file-input" accept="video/mpeg,.mpeg,.mpg" multiple>
        </div>
    </div>

    <script>
        document.addEventListener('DOMContentLoaded', () => {
            feather.replace();
            
            const fileInput = document.getElementById('fileInput');
            const selectFilesBtn = document.getElementById('selectFilesBtn');
            const videoPlayer = document.getElementById('videoPlayer');
            const status = document.getElementById('status');
            const clickArea = document.getElementById('clickArea');
            
            let files = [];
            let currentFileIndex = 0;
            
            selectFilesBtn.addEventListener('click', () => {
                fileInput.click();
            });
            
            fileInput.addEventListener('change', (e) => {
                files = Array.from(e.target.files);
                if (files.length > 0) {
                    status.textContent = `${files.length} files selected`;
                    playFile(0);
                }
            });
            
            let longPressTimer;
            const controls = document.querySelector('.controls');
            
            clickArea.addEventListener('mousedown', () => {
                longPressTimer = setTimeout(() => {
                    controls.classList.toggle('hidden');
                }, 1000);
            });

            clickArea.addEventListener('mouseup', () => {
                clearTimeout(longPressTimer);
            });

            clickArea.addEventListener('mouseleave', () => {
                clearTimeout(longPressTimer);
            });

            clickArea.addEventListener('click', (e) => {
                if (e.target === clickArea && files.length > 0) {
                    currentFileIndex = (currentFileIndex + 1) % files.length;
                    playFile(currentFileIndex);
                }
            });
            
            function playFile(index) {
                if (index >= 0 && index < files.length) {
                    const file = files[index];
                    const fileURL = URL.createObjectURL(file);
                    
                    videoPlayer.src = fileURL;
                    videoPlayer.load();
                    
                    videoPlayer.addEventListener('canplay', () => {
                        videoPlayer.play().catch(e => {
                            console.error('Autoplay prevented:', e);
                        });
                        status.textContent = `Playing ${index + 1}/${files.length}: ${file.name}`;
                        controls.classList.add('hidden');
                        
                        // Try to enter fullscreen automatically
                        if (videoPlayer.requestFullscreen) {
                            videoPlayer.requestFullscreen().catch(e => {
                                console.log('Fullscreen error:', e);
                            });
                        }
                    });
                    
                    videoPlayer.addEventListener('ended', () => {
                        videoPlayer.currentTime = 0;
                        videoPlayer.play();
                    });
                }
            }
            
            // Handle fullscreen
            clickArea.addEventListener('dblclick', () => {
                if (videoPlayer.requestFullscreen) {
                    videoPlayer.requestFullscreen();
                } else if (videoPlayer.webkitRequestFullscreen) {
                    videoPlayer.webkitRequestFullscreen();
                } else if (videoPlayer.msRequestFullscreen) {
                    videoPlayer.msRequestFullscreen();
                }
            });
        });
    </script>
</body>
</html>