-
Notifications
You must be signed in to change notification settings - Fork 265
Expand file tree
/
Copy pathVideoPlayer.java
More file actions
199 lines (155 loc) · 5.15 KB
/
VideoPlayer.java
File metadata and controls
199 lines (155 loc) · 5.15 KB
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
189
190
191
192
193
194
195
196
197
198
199
package com.google;
import java.util.*;
public class VideoPlayer {
private final VideoLibrary videoLibrary;
public boolean vidPlaying = false;
public boolean vidPaused = false;
String prevVid = "";
Video currentVid=null;
LinkedList<String> playlists = new LinkedList<String>();
public VideoPlayer() {
this.videoLibrary = new VideoLibrary();
}
public void numberOfVideos() {
System.out.printf("%s videos in the library%n", videoLibrary.getVideos().size());
}
public void showAllVideos() {
System.out.println("Here's a list of all available videos:");
List<Video> vids = this.videoLibrary.getVideos();
// Use a self-implemented comparator to sort videos by their titles.
Collections.sort(vids, new SortByTitle());
for (int i=0; i<vids.size();i++){
Video cVid = vids.get(i);
String name = cVid.getTitle();
String ident = cVid.getVideoId();
List<String> tags = cVid.getTags();
String tagNem = tags.toString().replaceAll(",","");
System.out.println(name+" ("+ident+") "+tagNem);
}
}
public void playVideo(String videoId) {
Video realVid = this.videoLibrary.getVideo(videoId);
String nem="";
if (realVid!=null){
while (vidPlaying){
stopVideo();
vidPlaying = false;
}
prevVid = realVid.getTitle();
currentVid = realVid;
nem = "Playing video: "+ prevVid;
vidPlaying = true;
}
else{
nem ="Cannot play video: Video does not exist";
}
System.out.println(nem);
}
public void stopVideo() {
if(!vidPlaying){
System.out.println("Cannot stop video: No video is currently playing");
}
else{
if(!prevVid.equals("")){
System.out.println("Stopping video: "+prevVid);
vidPlaying=false;
vidPaused=false;
}
}
}
public void playRandomVideo() {
//i
List<Video> vids = this.videoLibrary.getVideos();
Random r = new Random();
int rndmInt = r.nextInt(vids.size()-1);
String selectedV = vids.get(rndmInt).getVideoId();
//get length of vid system and select a random vid tween there and send that to the videoId!!
playVideo(selectedV);
}
public void pauseVideo() {
if(vidPaused){
System.out.println("Video already paused: "+prevVid);
}
else{
if(!vidPlaying){
System.out.println("Cannot pause video: No video is currently playing");
}
else{
vidPaused = true;
if(!prevVid.equals("")){
System.out.println("Pausing video: "+prevVid);
}
}
}
}
public void continueVideo() {
if(!vidPlaying){
System.out.println("Cannot continue video: No video is currently playing");
}
else{
if(vidPaused){
System.out.println("Continuing video: "+prevVid);
}
else{
System.out.println("Cannot continue video: Video is not paused");
}
}
}
public void showPlaying() {
if (vidPlaying){
String name = currentVid.getTitle();
String ident = currentVid.getVideoId();
List<String> tags = currentVid.getTags();
String tagNem = tags.toString().replaceAll(",","");
if(vidPaused){
System.out.println("Currently playing: "+name+" ("+ident+") "+tagNem+" - PAUSED");
}
else{
System.out.println("Currently playing: "+name+" ("+ident+") "+tagNem);
}
}
else{
System.out.println("No video is currently playing");
}
}
public void createPlaylist(String playlistName) {
VideoPlaylist v = new VideoPlaylist();
System.out.println("Successfully created new playlist: "+ playlistName);
}
public void addVideoToPlaylist(String playlistName, String videoId) {
System.out.println("addVideoToPlaylist needs implementation");
//add it deya....loaed the playist and check if it's there already tbh
}
public void showAllPlaylists() {
System.out.println("showAllPlaylists needs implementation");
// just implement a list of playlists and their names no?
}
public void showPlaylist(String playlistName) {
System.out.println("showPlaylist needs implementation");
//a list must be assigned to each playlist...to display the videos
}
public void removeFromPlaylist(String playlistName, String videoId) {
System.out.println("removeFromPlaylist needs implementation");
}
public void clearPlaylist(String playlistName) {
System.out.println("clearPlaylist needs implementation");
}
public void deletePlaylist(String playlistName) {
System.out.println("deletePlaylist needs implementation");
}
public void searchVideos(String searchTerm) {
System.out.println("searchVideos needs implementation");
}
public void searchVideosWithTag(String videoTag) {
System.out.println("searchVideosWithTag needs implementation");
}
public void flagVideo(String videoId) {
System.out.println("flagVideo needs implementation");
}
public void flagVideo(String videoId, String reason) {
System.out.println("flagVideo needs implementation");
}
public void allowVideo(String videoId) {
System.out.println("allowVideo needs implementation");
}
}