Class Video

java.lang.Object
fr.xxathyx.mediaplayer.video.Video

public class Video extends Object
The Video class is essential in the good functioning of things, its used everywhere across the plugin, it constitue a core part. A video instance bridge the gap between the original video file and the ressource. The video class has three constructors. Registered videos can be found here Main.getRegisteredVideos().

Video corresponds to an video configuration file, for each video that can be registered they have an configuration that is used as we can see here

invalid @link
TaskAsyncLoadConfiguration
. In the YAML configuration-file are related all informations about the video itself.
Since:
2021-08-23
Version:
1.0.0
Author:
Xxathyx
  • Constructor Summary

    Constructors
    Constructor
    Description
    Video(int index)
    Constructor for Video class, creates an Video variable according to a video index Integer.
    Video(Source source)
    Constructor for Video class, creates an Video variable according to an external source.
    Video(File file)
    Constructor for Video class, creates an Video variable according to a video configuration-file File.
    Video(String name)
    Constructor for Video class, creates an Video variable according to a String video name.
    Video(URL url)
    Constructor for Video class, creates an Video variable according to a live-stream URL url.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Creates a video configuration-file only accoding to a external source passed earlier in the constructor.
    void
    Creates a video configuration-file accoding to a original video file.
    void
    Deletes a video and its video folder.
    boolean
    equals(Video video)
    Gets whether two videos are equals.
    int
    Gets amount of audio channel of the video.
    Gets an List of the audio files contained in the audio folder, see getAudioFolder().
    Gets the folder containing all audio files.
    double
    Gets audio-offset of the video in seconds.
    org.bukkit.configuration.file.FileConfiguration
    Gets an FileConfiguration instance of the video configuration-file, wich grant access to the configuration data.
    Gets creation date of the video as a single String using the following european* schema : dd-mm-yyyyy hh:mm:ss.
    Gets the folder containing all related Minecraft data about the video.
    Gets the video description with the alternate color codes.
    Gets the video duration in hours.
    Gets the video configuration-file accoding to the values passed earlier in the constructors.
    Gets the video format as a String without the dot after the name.
    int
    Gets the video number of frames per second.
    Gets the video frames extension.
    Gets the folder containing all video frames.
    int
    Gets the video height.
    int
    Gets the video index registered has.
     
    Gets the folder containing all video instances.
    Gets the video name without extension.
    Gets the video length in megabyte as a String.
    Gets the video source passed earlier in the constructors.
    double
    Gets the write speed of the device, about how many bytes are wrote within a second, for a Video configuration-file for instance.
    Gets a String status short message on whether a video is loaded.
    Gets the streamed video original link.
    int
    Gets the total number of frames contained in the video.
    Gets a VideoData instance for the current video where its called from.
    Get the original video file.
    int
    Gets the total number of times the video has been viewed.
    double
    Gets the video audio intensity.
    int
    Gets the video width.
    boolean
    Gets whether the video has an audio track.
    boolean
    Gets whether a VideoData has enought space to be load on the partition.
    boolean
    Gets whether the video have audio enabled.
    boolean
    Gets wheter video-cache is compressed or not.
    boolean
    Gets whether the video format is compatible.
    boolean
    Gets whether the video is loaded.
    boolean
    Gets whether the video will be repeated when it ends.
    boolean
    Gets whether the video is in restricted mode.
    boolean
    Gets whether the video is streamed.
    void
    Runs a task that will load the Video.
    void
    setAudioOffset(double offset)
    Sets the video-audio offset.
    void
    setCompress(boolean compress)
    Sets compress status of the video-cache.
    void
    setDescription(String description)
    Sets the displayed video description.
    void
    setEnableAudio(boolean enableaudio)
    Sets whether the video audio will be played.
    void
    setFrameRate(double framerate)
    Sets how many frames would be displayed within a second.
    void
    setLoaded(boolean loaded)
    Sets whether a video is loaded, its used for texts purposes, see getStatus().
    void
    setLooping(boolean looping)
    Sets whether the video will be repeated when it ends.
    void
    setMinecraftHeight(int minecraftHeight)
    Sets the Minecraft video height in blocks-count.
    void
    setMinecraftWidth(int minecraftWidth)
    Sets the Minecraft video width in blocks-count.
    void
    setRealTimeRendering(boolean realtimerendering)
    Sets whether the video should be rendered in realtime or use a Cache system.
    void
    setRestricted(boolean restricted)
    Sets the video in restricted mode, the thumbnail appearance will change.
    void
    setRunOnStartup(boolean runonstartup)
    Sets whether a video should be launched on the plugin statup.
    void
    setShowFPS(boolean showfps)
    Sets whether the sent informations would contains the amount of frame per second.
    void
    setShowInformations(boolean showinformations)
    Sets whether the video informations will be sent to viewers.
    void
    setSkipDuplicatedFrames(boolean skipduplicatedframes)
    Sets whether the video skipping frames would be only duplicated ones.
    void
    setSpeed(double speed)
    Sets the video displaying speed.
    void
    setViews(int views)
    Sets the total amount of views, views corresponds to The number of times a video has been viewed
    void
    setVolume(double volume)
    Sets the video volume for being played.
    void
    Unloads a loaded video.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Video

      public Video(URL url)
      Constructor for Video class, creates an Video variable according to a live-stream URL url.
      Parameters:
      name - The live-stream direct url.
    • Video

      public Video(String name)
      Constructor for Video class, creates an Video variable according to a String video name.
      Parameters:
      name - The video name without extension.
    • Video

      public Video(int index)
      Constructor for Video class, creates an Video variable according to a video index Integer.

      Does search for that index in Main.getRegisteredVideos().

      Parameters:
      index - The video index.
    • Video

      public Video(File file)
      Constructor for Video class, creates an Video variable according to a video configuration-file File.

      Passed File can be non-existent.

      Parameters:
      file - The video configuration-file.
    • Video

      public Video(Source source)
      Constructor for Video class, creates an Video variable according to an external source.

      Passed Source can't be non-existent, needs to be created manually.

      Parameters:
      source - The external source.
  • Method Details

    • createConfiguration

      public void createConfiguration(File videoFile) throws FileNotFoundException, IOException, org.bukkit.configuration.InvalidConfigurationException
      Creates a video configuration-file accoding to a original video file.
      Parameters:
      file - The original video file.
      Throws:
      IOException - When failed or interrupted I/O operations occurs.
      org.bukkit.configuration.InvalidConfigurationException - When non-respect of YAML syntax.
      FileNotFoundException
    • createConfiguration

      public void createConfiguration() throws FileNotFoundException, IOException, org.bukkit.configuration.InvalidConfigurationException
      Creates a video configuration-file only accoding to a external source passed earlier in the constructor.
      Throws:
      IOException - When failed or interrupted I/O operations occurs.
      org.bukkit.configuration.InvalidConfigurationException - When non-respect of YAML syntax.
      FileNotFoundException
    • setEnableAudio

      public void setEnableAudio(boolean enableaudio) throws FileNotFoundException, IOException, org.bukkit.configuration.InvalidConfigurationException
      Sets whether the video audio will be played.
      Parameters:
      enableaudio - Whether the video audio will be played.
      Throws:
      FileNotFoundException - When the configuration File.exists() return false.
      IOException - When failed or interrupted I/O operations occurs.
      org.bukkit.configuration.InvalidConfigurationException - When non-respect of YAML syntax.
    • setVolume

      public void setVolume(double volume) throws FileNotFoundException, IOException, org.bukkit.configuration.InvalidConfigurationException
      Sets the video volume for being played.

      Note: The volume parameter is defined from 0 to 1.0, with 0 lowest and 1.0 highest. However if the volume value is above 1.0, then the hearing sound radius will be increased.

      Parameters:
      volume - The volume parameter from 0 to 1.0 and above 1.0 for higher radius.
      Throws:
      FileNotFoundException - When the configuration File.exists() return false.
      IOException - When failed or interrupted I/O operations occurs.
      org.bukkit.configuration.InvalidConfigurationException - When non-respect of YAML syntax.
    • setAudioOffset

      public void setAudioOffset(double offset) throws FileNotFoundException, IOException, org.bukkit.configuration.InvalidConfigurationException
      Sets the video-audio offset.

      Note: Audio offset is the countdown, once finished video frames will appear and thus the video begin, this is used to manually synchronize both audio and video.

      Parameters:
      offset - The audio-offset in seconds.
      Throws:
      FileNotFoundException - When the configuration File.exists() return false.
      IOException - When failed or interrupted I/O operations occurs.
      org.bukkit.configuration.InvalidConfigurationException - When non-respect of YAML syntax.
    • setDescription

      public void setDescription(String description) throws FileNotFoundException, IOException, org.bukkit.configuration.InvalidConfigurationException
      Sets the displayed video description.

      The video description is by default displayed in the showing informations while playing the video, and the

      invalid @link
      Interfaces#getVideos()
      interface.
      Parameters:
      description - The video description.
      Throws:
      FileNotFoundException - When the configuration File.exists() return false.
      IOException - When failed or interrupted I/O operations occurs.
      org.bukkit.configuration.InvalidConfigurationException - When non-respect of YAML syntax.
    • setFrameRate

      public void setFrameRate(double framerate) throws FileNotFoundException, IOException, org.bukkit.configuration.InvalidConfigurationException
      Sets how many frames would be displayed within a second.

      It is not recommended to change this parameter from the original video frame-rate, it could lead to freezing while the video being displayed.

      Parameters:
      framerate - The video frame-rate.
      Throws:
      FileNotFoundException - When the configuration File.exists() return false.
      IOException - When failed or interrupted I/O operations occurs.
      org.bukkit.configuration.InvalidConfigurationException - When non-respect of YAML syntax.
    • setSpeed

      public void setSpeed(double speed) throws FileNotFoundException, IOException, org.bukkit.configuration.InvalidConfigurationException
      Sets the video displaying speed.

      Note: A video reload is necessary to see these changes for the audio part.

      Parameters:
      speed - The video displaying speed.
      Throws:
      FileNotFoundException - When the configuration File.exists() return false.
      IOException - When failed or interrupted I/O operations occurs.
      org.bukkit.configuration.InvalidConfigurationException - When non-respect of YAML syntax.
    • setCompress

      public void setCompress(boolean compress) throws FileNotFoundException, IOException, org.bukkit.configuration.InvalidConfigurationException
      Sets compress status of the video-cache.

      Note: Video-cache is compressed by default.

      Parameters:
      restricted - Whether the video-cache should be compressed or not.
      Throws:
      FileNotFoundException - When the configuration File.exists() return false.
      IOException - When failed or interrupted I/O operations occurs.
      org.bukkit.configuration.InvalidConfigurationException - When non-respect of YAML syntax.
    • setRestricted

      public void setRestricted(boolean restricted) throws FileNotFoundException, IOException, org.bukkit.configuration.InvalidConfigurationException
      Sets the video in restricted mode, the thumbnail appearance will change.

      Note: A video reload is necessary to see these changes.

      Parameters:
      restricted - Whether the video would be in restricted method.
      Throws:
      FileNotFoundException - When the configuration File.exists() return false.
      IOException - When failed or interrupted I/O operations occurs.
      org.bukkit.configuration.InvalidConfigurationException - When non-respect of YAML syntax.
    • setLooping

      public void setLooping(boolean looping) throws FileNotFoundException, IOException, org.bukkit.configuration.InvalidConfigurationException
      Sets whether the video will be repeated when it ends.
      Parameters:
      looping - Whether the video will be repeated when it ends.
      Throws:
      FileNotFoundException - When the configuration File.exists() return false.
      IOException - When failed or interrupted I/O operations occurs.
      org.bukkit.configuration.InvalidConfigurationException - When non-respect of YAML syntax.
    • setRealTimeRendering

      public void setRealTimeRendering(boolean realtimerendering) throws FileNotFoundException, IOException, org.bukkit.configuration.InvalidConfigurationException
      Sets whether the video should be rendered in realtime or use a Cache system.

      Note: The realtime rendering shall be used to receive and render frames from a live stream for instance, or if the video is to long to be stored with the Cache system. Rendering and sending frames in realtime should be done asynchronously from the main one, but considering this option to not use a Cache system could result in a slight performance decrease.

      Parameters:
      realtimerendering - Whether the video should be rendered in realtime.
      Throws:
      FileNotFoundException - When the configuration File.exists() return false.
      IOException - When failed or interrupted I/O operations occurs.
      org.bukkit.configuration.InvalidConfigurationException - When non-respect of YAML syntax.
    • setSkipDuplicatedFrames

      public void setSkipDuplicatedFrames(boolean skipduplicatedframes) throws FileNotFoundException, IOException, org.bukkit.configuration.InvalidConfigurationException
      Sets whether the video skipping frames would be only duplicated ones.
      Parameters:
      skipduplicatedframes - Whether the video skipping frames would be only duplicated ones.
      Throws:
      FileNotFoundException - When the configuration File.exists() return false.
      IOException - When failed or interrupted I/O operations occurs.
      org.bukkit.configuration.InvalidConfigurationException - When non-respect of YAML syntax.
    • setShowInformations

      public void setShowInformations(boolean showinformations) throws FileNotFoundException, IOException, org.bukkit.configuration.InvalidConfigurationException
      Sets whether the video informations will be sent to viewers.
      Parameters:
      showinformations - Vhether the video informations will be sent to viewers.
      Throws:
      FileNotFoundException - When the configuration File.exists() return false.
      IOException - When failed or interrupted I/O operations occurs.
      org.bukkit.configuration.InvalidConfigurationException - When non-respect of YAML syntax.
    • setShowFPS

      public void setShowFPS(boolean showfps) throws FileNotFoundException, IOException, org.bukkit.configuration.InvalidConfigurationException
      Sets whether the sent informations would contains the amount of frame per second.
      Parameters:
      showfps - whether the sent informations would contains the amount of frame per second.
      Throws:
      FileNotFoundException - When the configuration File.exists() return false.
      IOException - When failed or interrupted I/O operations occurs.
      org.bukkit.configuration.InvalidConfigurationException - When non-respect of YAML syntax.
    • setRunOnStartup

      public void setRunOnStartup(boolean runonstartup) throws FileNotFoundException, IOException, org.bukkit.configuration.InvalidConfigurationException
      Sets whether a video should be launched on the plugin statup.
      Parameters:
      runonstartup - Whether a video should be launched on the plugin statup.
      Throws:
      FileNotFoundException - When the configuration File.exists() return false.
      IOException - When failed or interrupted I/O operations occurs.
      org.bukkit.configuration.InvalidConfigurationException - When non-respect of YAML syntax.
    • setMinecraftWidth

      public void setMinecraftWidth(int minecraftWidth) throws FileNotFoundException, IOException, org.bukkit.configuration.InvalidConfigurationException
      Sets the Minecraft video width in blocks-count.
      Parameters:
      minecraftWidth - The Minecraft video width in blocks-count.
      Throws:
      FileNotFoundException - When the configuration File.exists() return false.
      IOException - When failed or interrupted I/O operations occurs.
      org.bukkit.configuration.InvalidConfigurationException - When non-respect of YAML syntax.
    • setMinecraftHeight

      public void setMinecraftHeight(int minecraftHeight) throws FileNotFoundException, IOException, org.bukkit.configuration.InvalidConfigurationException
      Sets the Minecraft video height in blocks-count.
      Parameters:
      minecraftHeight - The Minecraft video height in blocks-count.
      Throws:
      FileNotFoundException - When the configuration File.exists() return false.
      IOException - When failed or interrupted I/O operations occurs.
      org.bukkit.configuration.InvalidConfigurationException - When non-respect of YAML syntax.
    • setLoaded

      public void setLoaded(boolean loaded) throws FileNotFoundException, IOException, org.bukkit.configuration.InvalidConfigurationException
      Sets whether a video is loaded, its used for texts purposes, see getStatus().
      Parameters:
      loaded - Whether a video is loaded.
      Throws:
      FileNotFoundException - When the configuration File.exists() return false.
      IOException - When failed or interrupted I/O operations occurs.
      org.bukkit.configuration.InvalidConfigurationException - When non-respect of YAML syntax.
    • setViews

      public void setViews(int views) throws FileNotFoundException, IOException, org.bukkit.configuration.InvalidConfigurationException
      Sets the total amount of views, views corresponds to The number of times a video has been viewed
      Parameters:
      views - The number of views.
      Throws:
      FileNotFoundException - When the configuration File.exists() return false.
      IOException - When failed or interrupted I/O operations occurs.
      org.bukkit.configuration.InvalidConfigurationException - When non-respect of YAML syntax.
    • load

      public void load()
      Runs a task that will load the Video. Loading a video can take time according to the video lenght and their options, see getSize().

      This is the same as calling TaskAsyncLoadVideo.

    • unload

      public void unload() throws IOException, org.bukkit.configuration.InvalidConfigurationException
      Unloads a loaded video.

      Note: This method shall be called asynchronously from the main thread, since its thread-safe and performs a lot of I/O opperations.

      Throws:
      IOException - When failed or interrupted I/O operations occurs.
      org.bukkit.configuration.InvalidConfigurationException - When non-respect of YAML syntax.
    • delete

      public void delete() throws IOException
      Deletes a video and its video folder.

      Note: This method shall be called asynchronously from the main thread, since its thread-safe and performs a lot of I/O opperations.

      Throws:
      IOException - When failed or interrupted I/O operations occurs.
    • isCompatible

      public boolean isCompatible()
      Gets whether the video format is compatible.
      Returns:
      Whether the video format is compatible.
    • isStreamed

      public boolean isStreamed()
      Gets whether the video is streamed.
      Returns:
      Whether the video is streamed.
    • isLoaded

      public boolean isLoaded()
      Gets whether the video is loaded.

      Note: This method shall be called asynchronously from the main thread, since its thread-safe and performs a lot of I/O opperations.

      Returns:
      Whether the video is loaded.
    • hasAudio

      public boolean hasAudio()
      Gets whether the video has an audio track.
      Returns:
      Whether the video has audio.
    • equals

      public boolean equals(Video video)
      Gets whether two videos are equals.

      Note: This method checks if two videos are equals using their file lenght, and the video names.

      Returns:
      Whether two videos are equals.
    • getStreamURL

      public URL getStreamURL() throws MalformedURLException
      Gets the streamed video original link.
      Returns:
      The streamed video original link.
      Throws:
      MalformedURLException
    • getFramesFolder

      public File getFramesFolder()
      Gets the folder containing all video frames.

      The folder is empty until the video is loaded.

      Returns:
      The folder containing all video frames.
    • getAudioFolder

      public File getAudioFolder()
      Gets the folder containing all audio files.

      The folder is empty until the video is loaded.

      Returns:
      The folder containing all audio files.
    • getDataFolder

      public File getDataFolder()
      Gets the folder containing all related Minecraft data about the video.

      The folder is empty until the video is loaded.

      Returns:
      The folder containing all related Minecraft video data.
    • isCacheCompressed

      public boolean isCacheCompressed()
      Gets wheter video-cache is compressed or not.

      Compression is enabled by default

      Returns:
      Wheter video-cache is compressed or not.
    • getInstancesFolder

      public File getInstancesFolder()
      Gets the folder containing all video instances.

      The folder is empty until a video has been played once time.

      Returns:
      The folder containing video instances.
    • getInstances

      public ArrayList<VideoInstance> getInstances()
    • getName

      public String getName()
      Gets the video name without extension.
      Returns:
      The video name without extension.
    • getDescription

      public String getDescription()
      Gets the video description with the alternate color codes.
      Returns:
      The video description with the alternate color codes.
    • getVideoFile

      public File getVideoFile()
      Get the original video file.

      The original video file path is stored in the video configuration-file.

      Returns:
      The original video file.
    • isAudioEnabled

      public boolean isAudioEnabled()
      Gets whether the video have audio enabled.
      Returns:
      Whether the video have audio enabled.
    • getAudioFiles

      public List<File> getAudioFiles()
      Gets an List of the audio files contained in the audio folder, see getAudioFolder().

      The returned List is empty until the video is loaded.

      Returns:
      The folder containing audio files.
    • getVolume

      public double getVolume()
      Gets the video audio intensity.
      Returns:
      The video audio intensity
    • getAudioChannels

      public int getAudioChannels()
      Gets amount of audio channel of the video.
      Returns:
      The number of audio channels
    • getAudioOffset

      public double getAudioOffset()
      Gets audio-offset of the video in seconds.
      Returns:
      The audio-offset of the video
    • getFrameRate

      public int getFrameRate()
      Gets the video number of frames per second.
      Returns:
      The video number of frames per second.
    • getTotalFrames

      public int getTotalFrames()
      Gets the total number of frames contained in the video.
      Returns:
      The total number of frames contained in the video.
    • getWidth

      public int getWidth()
      Gets the video width.
      Returns:
      The video width.
    • getHeight

      public int getHeight()
      Gets the video height.
      Returns:
      The video heigt.
    • getDuration

      public String getDuration()
      Gets the video duration in hours.
      Returns:
      The video duration in hours.
    • getSpeed

      public double getSpeed()
      Gets the write speed of the device, about how many bytes are wrote within a second, for a Video configuration-file for instance.

      This method is used to know how long load a video will take.

      Returns:
      The write speed of the device.
    • getFormat

      public String getFormat()
      Gets the video format as a String without the dot after the name.
      Returns:
      The video format.
    • getSize

      public String getSize()
      Gets the video length in megabyte as a String.

      Note: The video length value can be retrieve using the following calculations: getVideoFile().length()*Math.pow(10, -6)

      Returns:
      The video length in megabyte.
    • isRestricted

      public boolean isRestricted()
      Gets whether the video is in restricted mode.

      In restricted mode, the thumbnail appear different.

      Returns:
      The video length in megabyte.
    • isLoopping

      public boolean isLoopping()
      Gets whether the video will be repeated when it ends.
      Returns:
      Whether the video will be repeated when it ends.
    • getCreation

      public String getCreation()
      Gets creation date of the video as a single String using the following european* schema : dd-mm-yyyyy hh:mm:ss.
      Returns:
      The video creation date.
    • getViews

      public int getViews()
      Gets the total number of times the video has been viewed.
      Returns:
      The total number of times the video has been viewed.
    • getIndex

      public int getIndex()
      Gets the video index registered has.
      Returns:
      The video index created has.
    • getFramesExtension

      public String getFramesExtension()
      Gets the video frames extension.

      Note: The frames extension for GIF files aren't the same as for common videos files. Portable Network Graphics (png) are used for GIF instead of the default JPG extension for videos.

      Returns:
      The video frames extension.
    • getStatus

      public String getStatus()
      Gets a String status short message on whether a video is loaded.

      This method is used for

      invalid @link
      Interfaces#getVideos()
      .
      Returns:
      A status short message on whether a video is loaded.
    • hasEnoughtSpace

      public boolean hasEnoughtSpace()
      Gets whether a VideoData has enought space to be load on the partition.
      Returns:
      Whether the device has enought space to load a video on.
    • getVideoData

      public VideoData getVideoData()
      Gets a VideoData instance for the current video where its called from.

      Note: Every time the class instantiated the duplicated frames list is loaded, so do not call getVideoData() every time for no reason, instead store a new VideoData variable to avoid performances issues.

      Returns:
      A video instance for the current video where its called from.
    • getConfigFile

      public org.bukkit.configuration.file.FileConfiguration getConfigFile()
      Gets an FileConfiguration instance of the video configuration-file, wich grant access to the configuration data.

      This method isn't usable directly, its used on class getters method such as getName() to access data.

      Returns:
      FileConfiguration instance of the video configuration-file.
    • getFile

      public File getFile()
      Gets the video configuration-file accoding to the values passed earlier in the constructors.

      The configuration file does not need to exist, specially if the createConfiguration(File) will be called next.

      Returns:
      The video configuration-file.
    • getSource

      public Source getSource()
      Gets the video source passed earlier in the constructors.
      Returns:
      The video source.