Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
155 views
in Technique[技术] by (71.8m points)

java - YT videos synchronous viewing backend

i want create service that let users watch youtube videos (music tracks for example) together with chatting and video ordering. Server contains rooms and YT videos links in them.

thisRoom class (I remove @Column annotations removed)

public class Room {

    @Id
    @GeneratedValue(...)
    private Long id;

    private String name;
    private Date creationDate;

    @ManyToOne(fetch = FetchType.LAZY)
    private User owner;

    @OneToMany(cascade = CascadeType.REMOVE, fetch = FetchType.LAZY)
    private Set<Track> tracks = new HashSet<>();

    @ManyToMany(cascade = CascadeType.REFRESH, fetch = FetchType.LAZY)
    @JoinTable(...)
    private Set<User> admins = new HashSet<>();

    @ManyToMany(cascade = CascadeType.REFRESH, fetch = FetchType.LAZY)
    @JoinTable(...)
    private Set<User> users = new HashSet<>();

    @OneToMany(cascade = CascadeType.REFRESH, fetch = FetchType.LAZY)
    @JoinTable(...)
    private Set<User> blackList = new HashSet<>();
}

Track class

public class Track {

    @Id
    @GeneratedValue(...)
    private Long id;

    private int trackOrder;
    private String link;
    private LocalDateTime started = LocalDateTime.now();

    @ManyToOne(fetch = FetchType.EAGER)
    private User requester;
}

and User class

public class User implements UserDetails {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @ElementCollection(targetClass = UserRole.class, fetch = FetchType.EAGER)
    @CollectionTable(...)
    @Enumerated(EnumType.STRING)
    private Set<UserRole> roles = new HashSet<>(Collections.singletonList(UserRole.ROLE_USER));

    private String username;
    private String email;
    private String password;

    @OneToMany(mappedBy = "owner", fetch = FetchType.LAZY)
    private Set<Room> ownedRooms = new HashSet<>();

    @ManyToMany(mappedBy = "admins", fetch = FetchType.LAZY)
    private Set<Room> adminRooms = new HashSet<>();

    @ManyToMany(mappedBy = "users", fetch = FetchType.LAZY)
    private Set<Room> rooms = new HashSet<>();
}

Videos playing on clients must be sync, room admin or owner can skip video and server will send message to all users in room by websoket about this. When video ends server must update video order and send message to clients to play next video in queue.

My problem is here - how server must detect when video ends by itself?

I think about TimerTask for each room but I not sure about perfomance of this solve.

Also I read about WEBRTC and I don't understand how to use it in my case Probably my app arcitecture have fundamental errors,

question from:https://stackoverflow.com/questions/65919201/yt-videos-synchronous-viewing-backend

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...