< Summary

Class:VideoPluginWrapper_Native
Assembly:VideoComponents
File(s):/tmp/workspace/explorer-desktop/unity-renderer-desktop/Assets/Scripts/MainScripts/DCL/Components/Video/VideoPluginWrapper_Native.cs
Covered lines:0
Uncovered lines:38
Coverable lines:38
Total lines:115
Line coverage:0% (0 of 38)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
VideoPluginWrapper_Native()0%2100%
Create(...)0%2100%
Remove(...)0%2100%
TextureUpdate(...)0%2100%
PrepareTexture(...)0%2100%
Play(...)0%6200%
Pause(...)0%2100%
SetVolume(...)0%2100%
GetHeight(...)0%2100%
GetWidth(...)0%2100%
GetTime(...)0%2100%
GetDuration(...)0%2100%
GetState(...)0%56700%
GetError(...)0%2100%
SetTime(...)0%2100%
SetPlaybackRate(...)0%2100%
SetLoop(...)0%2100%

File(s)

/tmp/workspace/explorer-desktop/unity-renderer-desktop/Assets/Scripts/MainScripts/DCL/Components/Video/VideoPluginWrapper_Native.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using DCL.Components.Video.Plugin;
 4using UnityEngine;
 5
 6public class VideoPluginWrapper_Native : IVideoPluginWrapper
 7{
 08    private Dictionary<string, DCLVideoPlayer> videoPlayers = new Dictionary<string, DCLVideoPlayer>();
 9
 10    public void Create(string id, string url, bool useHls)
 11    {
 012        videoPlayers.Add(id, new DCLVideoPlayer(url));
 013    }
 14
 15    public void Remove(string id)
 16    {
 017        videoPlayers[id].Dispose();
 018        videoPlayers.Remove(id);
 019    }
 20
 21    public void TextureUpdate(string id)
 22    {
 023        videoPlayers[id].UpdateVideoTexture();
 024    }
 25
 26    public Texture2D PrepareTexture(string id)
 27    {
 028        videoPlayers[id].PrepareTexture();
 029        return videoPlayers[id].GetTexture();
 30    }
 31
 32    public void Play(string id, float startTime)
 33    {
 034        videoPlayers[id].Play();
 035        if (startTime > 0)
 36        {
 037            videoPlayers[id].SetSeekTime(startTime);
 38        }
 039    }
 40
 41    public void Pause(string id)
 42    {
 043        videoPlayers[id].Pause();
 044    }
 45
 46    public void SetVolume(string id, float volume)
 47    {
 048        videoPlayers[id].SetVolume(volume);
 049    }
 50
 51    public int GetHeight(string id)
 52    {
 053        return videoPlayers[id].GetVideoHeight();
 54    }
 55
 56    public int GetWidth(string id)
 57    {
 058        return videoPlayers[id].GetVideoWidth();
 59    }
 60
 61    public float GetTime(string id)
 62    {
 063        return videoPlayers[id].GetPlaybackPosition();
 64    }
 65
 66    public float GetDuration(string id)
 67    {
 068        return videoPlayers[id].GetDuration();
 69    }
 70
 71    public VideoState GetState(string id)
 72    {
 073        DCLVideoPlayer videoPlayer = videoPlayers[id];
 074        switch (videoPlayer.GetState())
 75        {
 76            case DCLVideoPlayer.VideoPlayerState.Loading:
 077                return VideoState.LOADING;
 78            case DCLVideoPlayer.VideoPlayerState.Error:
 079                return VideoState.ERROR;
 80            case DCLVideoPlayer.VideoPlayerState.Ready:
 081                if (videoPlayer.GetTexture() == null)
 82                {
 083                    return VideoState.READY;
 84                }
 85                break;
 86
 87        }
 88
 089        if (videoPlayer.IsBuffering())
 90        {
 091            return VideoState.BUFFERING;
 92        }
 093        return videoPlayer.IsPlaying() ? VideoState.PLAYING : VideoState.PAUSED;
 94    }
 95
 96    public string GetError(string id)
 97    {
 098        return "";
 99    }
 100
 101    public void SetTime(string id, float second)
 102    {
 0103        videoPlayers[id].SetSeekTime(second);
 0104    }
 105
 106    public void SetPlaybackRate(string id, float playbackRate)
 107    {
 0108        videoPlayers[id].SetPlaybackRate(playbackRate);
 0109    }
 110
 111    public void SetLoop(string id, bool loop)
 112    {
 0113        videoPlayers[id].SetLoop(loop);
 0114    }
 115}