Пример #1
0
        public ActionResult ProgramTongji(int id)
        {
            int    A, B, C;
            string VideoName = "";

            if (id == 0)
            {
                A         = unitOfWork.pingjiasRepository.Get(filter: u => u.PingjiaValue == 0.3f).Count();
                B         = unitOfWork.pingjiasRepository.Get(filter: u => u.PingjiaValue == 0.5f).Count();
                C         = unitOfWork.pingjiasRepository.Get(filter: u => u.PingjiaValue == 0.8f).Count();
                VideoName = "全部";
            }
            else
            {
                A         = unitOfWork.pingjiasRepository.Get(filter: u => u.VideoId == id && u.PingjiaValue == 0.3f).Count();
                B         = unitOfWork.pingjiasRepository.Get(filter: u => u.VideoId == id && u.PingjiaValue == 0.5f).Count();
                C         = unitOfWork.pingjiasRepository.Get(filter: u => u.VideoId == id && u.PingjiaValue == 0.8f).Count();
                VideoName = VideoServices.GetVideoNameById(id);
            }


            int AA = unitOfWork.pingjiasRepository.Get(filter: u => u.PingjiaValue == 0.3f).Count();
            int BB = unitOfWork.pingjiasRepository.Get(filter: u => u.PingjiaValue == 0.5f).Count();
            int CC = unitOfWork.pingjiasRepository.Get(filter: u => u.PingjiaValue == 0.8f).Count();

            ViewBag.A         = A;
            ViewBag.B         = B;
            ViewBag.C         = C;
            ViewBag.AA        = AA;
            ViewBag.BB        = BB;
            ViewBag.CC        = CC;
            ViewBag.VideoName = VideoName;
            return(View());
        }
Пример #2
0
        public void GetVideoByIdWithComments_ShouldGetById()
        {
            var videoRepositoryMock   = new Mock <IRepository <Video> >();
            var unitOfWorkMock        = new Mock <IUnitOfWork>();
            var commentRepositoryMock = new Mock <IRepository <Comment> >();

            var videos = new List <Video>();

            Guid id = Guid.NewGuid();

            var video = new Video();

            video.Id = id;

            videos.Add(video);

            videoRepositoryMock.Setup(x => x.All("Comments.Author"))
            .Returns(videos.AsQueryable());

            VideoServices videoService = new VideoServices(videoRepositoryMock.Object, unitOfWorkMock.Object, commentRepositoryMock.Object);

            var newVideo = videoService.GetVideoByIdWithComments(id);

            videoRepositoryMock.Verify(x => x.All("Comments.Author"), Times.Once());
            Assert.Same(video, newVideo);
        }
Пример #3
0
        public void UploadVideo_ShouldCreateVideo()
        {
            var videoRepositoryMock   = new Mock <IRepository <Video> >();
            var unitOfWorkMock        = new Mock <IUnitOfWork>();
            var commentRepositoryMock = new Mock <IRepository <Comment> >();

            Video video = null;

            videoRepositoryMock.Setup(x => x.Add(It.IsAny <Video>()))
            .Callback <Video>(r => video = r);;

            Guid id = Guid.NewGuid();

            VideoServices videoService = new VideoServices(videoRepositoryMock.Object, unitOfWorkMock.Object, commentRepositoryMock.Object);

            VidconfileUser user = new VidconfileUser();

            byte[] videoData    = new byte[2];
            string thumbnailUrl = "far";
            string description  = "hi";
            string title        = "fasd";

            videoService.UploadVideo(user, videoData, description, thumbnailUrl, title);

            Assert.Same(user, video.Uploader);
            Assert.Same(videoData, video.VideoData);
            Assert.Same(thumbnailUrl, video.ThumbnailUrl);
            Assert.Same(description, video.Description);
            Assert.Same(title, video.Title);

            videoRepositoryMock.Verify(x => x.Add(It.IsAny <Video>()), Times.Once());
            unitOfWorkMock.Verify(x => x.Commit(), Times.Once());
        }
Пример #4
0
        public void ChangeViewsOfVideo_NullVideo_ShouldThrow()
        {
            var videoRepositoryMock   = new Mock <IRepository <Video> >();
            var unitOfWorkMock        = new Mock <IUnitOfWork>();
            var commentRepositoryMock = new Mock <IRepository <Comment> >();

            VideoServices videoService = new VideoServices(videoRepositoryMock.Object, unitOfWorkMock.Object, commentRepositoryMock.Object);

            Video video = null;
            ulong views = 0;

            string message = Assert
                             .Throws <NullReferenceException>(() => videoService.ChangeViewsOfVideo(video, views))
                             .Message;

            Assert.Equal("video cannot be null", message);
        }
Пример #5
0
        // GET: /Video/
        public ActionResult Index(int?page)
        {
            LogHelper.Info("查看视频");
            Pager pager = new Pager();

            pager.table      = "AdsVideo";
            pager.strwhere   = "1=1";
            pager.PageSize   = 20;
            pager.PageNo     = page ?? 1;
            pager.FieldKey   = "VideoId";
            pager.FiledOrder = "VideoId desc";


            IList <AdsVideo> videoList = VideoServices.GetListForPageList(pager);
            var videoListAsIPageList   = new StaticPagedList <AdsVideo>(videoList, pager.PageNo, pager.PageSize, pager.Amount);

            return(View(videoListAsIPageList));
        }
Пример #6
0
        public void ChangeViewsOfVideo_ShouldChangeViews()
        {
            var videoRepositoryMock   = new Mock <IRepository <Video> >();
            var unitOfWorkMock        = new Mock <IUnitOfWork>();
            var commentRepositoryMock = new Mock <IRepository <Comment> >();

            VideoServices videoService = new VideoServices(videoRepositoryMock.Object, unitOfWorkMock.Object, commentRepositoryMock.Object);

            Video video = new Video();
            ulong views = 2;

            videoService.ChangeViewsOfVideo(video, views);

            videoRepositoryMock.Verify(x => x.Update(video), Times.Once);
            unitOfWorkMock.Verify(x => x.Commit(), Times.Once);

            Assert.Equal(views, video.Views);
        }
Пример #7
0
        public void GetAllVideos_ShouldGetAll()
        {
            var videoRepositoryMock   = new Mock <IRepository <Video> >();
            var unitOfWorkMock        = new Mock <IUnitOfWork>();
            var commentRepositoryMock = new Mock <IRepository <Comment> >();

            IQueryable <Video> videos = new List <Video>().AsQueryable();

            videoRepositoryMock.Setup(x => x.All())
            .Returns(videos);

            VideoServices videoService = new VideoServices(videoRepositoryMock.Object, unitOfWorkMock.Object, commentRepositoryMock.Object);

            var allVideos = videoService.GetAllVideos();

            videoRepositoryMock.Verify(x => x.All(), Times.Once());

            Assert.Same(videos, allVideos);
        }
Пример #8
0
        public void GetVideoById_ShouldGetById()
        {
            var videoRepositoryMock   = new Mock <IRepository <Video> >();
            var unitOfWorkMock        = new Mock <IUnitOfWork>();
            var commentRepositoryMock = new Mock <IRepository <Comment> >();

            Video video = new Video();

            Guid id = Guid.NewGuid();

            videoRepositoryMock.Setup(x => x.GetById(id))
            .Returns(video);

            VideoServices videoService = new VideoServices(videoRepositoryMock.Object, unitOfWorkMock.Object, commentRepositoryMock.Object);

            var newVideo = videoService.GetVideoById(id);

            videoRepositoryMock.Verify(x => x.GetById(id), Times.Once());
            Assert.Same(video, newVideo);
        }
Пример #9
0
        public void UploadVideo_NullDescription_ShouldThrow()
        {
            var videoRepositoryMock   = new Mock <IRepository <Video> >();
            var unitOfWorkMock        = new Mock <IUnitOfWork>();
            var commentRepositoryMock = new Mock <IRepository <Comment> >();

            var videos = new List <Video>();

            Guid id = Guid.NewGuid();

            VideoServices videoService = new VideoServices(videoRepositoryMock.Object, unitOfWorkMock.Object, commentRepositoryMock.Object);

            VidconfileUser user = new VidconfileUser();

            byte[] videoData    = new byte[4];
            string thumbnailUrl = "asd";
            string title        = "test";

            string message = Assert.Throws <NullReferenceException>(() => videoService.UploadVideo(user, videoData, null, thumbnailUrl, title))
                             .Message;

            Assert.Same("description cannot be null", message);
        }
Пример #10
0
        private IEnumerator VideoPathPreparing(string path, bool playImmediately, IPathPreparedListener listener)
        {
            if (_cachedVideoPaths.ContainsKey(path))
            {
                listener.OnPathPrepared(_cachedVideoPaths[path], playImmediately);
                yield break;
            }

#if UNITY_EDITOR
            _lastEventMsg = "Path Preparing";
#endif

            if (UMPSettings.RuntimePlatform == UMPSettings.Platforms.Android)
            {
                /// Check if we try to play exported videos and wait when export process will be completed
                var exptPaths = UMPSettings.Instance.AndroidExportedPaths;
                var filePath  = path.Replace("file:///", "");

                foreach (var exptPath in exptPaths)
                {
                    if (exptPath.Contains(filePath))
                    {
                        while (!_isExportCompleted)
                        {
                            yield return(null);
                        }

                        if (_cachedVideoPaths.ContainsKey(filePath))
                        {
                            listener.OnPathPrepared(_cachedVideoPaths[filePath], playImmediately);
                            yield break;
                        }

                        break;
                    }
                }

                if ((_mediaPlayer.Options as PlayerOptionsAndroid).PlayerType ==
                    PlayerOptionsAndroid.PlayerTypes.LibVLC &&
                    MediaPlayerHelper.IsAssetsFile(path))
                {
                    var tempFilePath = System.IO.Path.Combine(Application.temporaryCachePath, filePath);
                    if (File.Exists(tempFilePath))
                    {
                        _cachedVideoPaths.Add(path, tempFilePath);
                        listener.OnPathPrepared(tempFilePath, playImmediately);
                        yield break;
                    }

                    var data = new byte[0];

#if UNITY_2017_2_OR_NEWER
                    var www = UnityWebRequest.Get(System.IO.Path.Combine(Application.streamingAssetsPath, filePath));
                    yield return(www.SendWebRequest());

                    data = www.downloadHandler.data;
#else
                    var www = new WWW(System.IO.Path.Combine(Application.streamingAssetsPath, filePath));
                    yield return(www);

                    data = www.bytes;
#endif
                    if (string.IsNullOrEmpty(www.error))
                    {
                        var tempFile = new FileInfo(tempFilePath);
                        tempFile.Directory.Create();
                        File.WriteAllBytes(tempFile.FullName, data);
                        _cachedVideoPaths.Add(path, tempFilePath);
                        path = tempFilePath;
                    }
                    else
                    {
                        Debug.LogError("Can't create temp file from asset folder: " + www.error);
                    }

                    www.Dispose();
                }
            }

            if (_videoServices.ValidUrl(path))
            {
                Video serviceVideo = null;
                _isParsing = true;

                yield return(_videoServices.GetVideos(path, (videos) =>
                {
                    _isParsing = false;
                    serviceVideo = VideoServices.FindVideo(videos, int.MaxValue, int.MaxValue);
                }, (error) =>
                {
                    _isParsing = false;
                    Debug.LogError(string.Format("[UniversalMediaPlayer.GetVideos] {0}", error));
                    OnPlayerEncounteredError();
                }));

                if (serviceVideo == null)
                {
                    Debug.LogError("[UniversalMediaPlayer.VideoPathPreparing] Can't get service video information");
                    OnPlayerEncounteredError();
                }
                else
                {
                    if (serviceVideo is YoutubeVideo)
                    {
                        yield return((serviceVideo as YoutubeVideo).Decrypt(UMPSettings.Instance.YoutubeDecryptFunction, (error) =>
                        {
                            Debug.LogError(string.Format("[UniversalMediaPlayer.Decrypt] {0}", error));
                            OnPlayerEncounteredError();
                        }));
                    }

                    path = serviceVideo.Url;
                }
            }

            listener.OnPathPrepared(path, playImmediately);
            yield return(null);
        }
Пример #11
0
#pragma warning restore 0414

        private void Awake()
        {
#if UNITY_EDITOR
#if UNITY_4 || UNITY_5 || UNITY_2017_1
            EditorApplication.playmodeStateChanged += HandleOnPlayModeChanged;
#else
            EditorApplication.playModeStateChanged += HandleOnPlayModeChanged;
#endif
#endif

            if (UMPSettings.Instance.UseAudioSource && (_desktopAudioOutputs == null || _desktopAudioOutputs.Length <= 0))
            {
                var audioOutput = gameObject.AddComponent <UMPAudioOutput>();
                _desktopAudioOutputs = new UMPAudioOutput[] { audioOutput };
            }

            PlayerOptions options = new PlayerOptions(null);

            switch (UMPSettings.RuntimePlatform)
            {
            case UMPSettings.Platforms.Win:
            case UMPSettings.Platforms.Mac:
            case UMPSettings.Platforms.Linux:
                var standaloneOptions = new PlayerOptionsStandalone(null)
                {
                    FixedVideoSize = _useFixedSize ? new Vector2(_fixedVideoWidth, _fixedVideoHeight) : Vector2.zero,
                    AudioOutputs   = _desktopAudioOutputs,
                    //DirectAudioDevice = "Digital Audio",
                    HardwareDecoding = _desktopHardwareDecoding,
                    FlipVertically   = _desktopFlipVertically,
                    VideoBufferSize  = _desktopVideoBufferSize,
                    UseTCP           = _desktopRtspOverTcp,
                    FileCaching      = _desktopFileCaching,
                    LiveCaching      = _desktopLiveCaching,
                    DiskCaching      = _desktopDiskCaching,
                    NetworkCaching   = _desktopNetworkCaching
                };

                if (_desktopOutputToFile)
                {
                    standaloneOptions.RedirectToFile(_desktopDisplayOutput, _desktopOutputFilePath);
                }

                standaloneOptions.SetLogDetail(_logDetail, UnityConsoleLogging);
                options = standaloneOptions;
                break;

            case UMPSettings.Platforms.Android:
                var androidOptions = new PlayerOptionsAndroid(null)
                {
                    FixedVideoSize       = _useFixedSize ? new Vector2(_fixedVideoWidth, _fixedVideoHeight) : Vector2.zero,
                    PlayerType           = _androidPlayerType,
                    HardwareAcceleration = _androidHardwareAcceleration,
                    OpenGLDecoding       = _androidOpenGLDecoding,
                    VideoChroma          = _androidVideoChroma,
                    PlayInBackground     = _androidPlayInBackground,
                    UseTCP         = _androidRtspOverTcp,
                    NetworkCaching = _androidNetworkCaching
                };

                options = androidOptions;

                if (_exportedHandlerEnum == null)
                {
                    _exportedHandlerEnum = AndroidExpoterdHandler();
                    StartCoroutine(_exportedHandlerEnum);
                }

                break;

            case UMPSettings.Platforms.iOS:
                var iphoneOptions = new PlayerOptionsIPhone(null)
                {
                    FixedVideoSize         = _useFixedSize ? new Vector2(_fixedVideoWidth, _fixedVideoHeight) : Vector2.zero,
                    PlayerType             = _iphonePlayerType,
                    FlipVertically         = _iphoneFlipVertically,
                    VideoToolbox           = _iphoneVideoToolbox,
                    VideoToolboxFrameWidth = _iphoneVideoToolboxMaxFrameWidth,
                    VideoToolboxAsync      = _iphoneVideoToolboxAsync,
                    VideoToolboxWaitAsync  = _iphoneVideoToolboxWaitAsync,
                    PlayInBackground       = _iphonePlayInBackground,
                    UseTCP          = _iphoneRtspOverTcp,
                    PacketBuffering = _iphonePacketBuffering,
                    MaxBufferSize   = _iphoneMaxBufferSize,
                    MinFrames       = _iphoneMinFrames,
                    Infbuf          = _iphoneInfbuf,
                    Framedrop       = _iphoneFramedrop,
                    MaxFps          = _iphoneMaxFps
                };

                options = iphoneOptions;
                break;
            }

            _mediaPlayer = new MediaPlayer(this, _renderingObjects, options);

            // Create scpecial parser to add possibiity of get video link from different video hosting servies (like youtube)
            _videoServices = new VideoServices(this);

            // Attach scecial listeners to MediaPlayer instance
            AddListeners();
            // Create additional media player for add smooth loop possibility
            if (_loopSmooth)
            {
                _mediaPlayerLoop = new MediaPlayer(this, _mediaPlayer);
                _mediaPlayerLoop.VideoOutputObjects = null;
                _mediaPlayerLoop.EventManager.RemoveAllEvents();
            }
        }
Пример #12
0
        public void Execute()
        {
            // Trace.WriteLine("现在时间是:" + DateTime.Now);
            lock (_lock)
            {
                if (_shuttingDown)
                {
                    return;
                }

                ILoggingService _logger = new LoggingService();
                try
                {
                    VideoServices       videoServices       = new VideoServices();
                    ReservationServices reservationServices = new ReservationServices();
                    CacheService        cacheServices       = new CacheService();

                    var videos = videoServices.GetNoticedElementsAsync().Result;

                    //_logger.Info("消息发送处理视频:" + videos.Count() + "条");
                    foreach (var video in videos)
                    {
                        var res = video.Reservations;
                        //_logger.Info("Reservations.Any:" + video.Reservations.Any());
                        if (!video.Reservations.Any())
                        {
                            continue;
                        }

                        string accesstoken;
                        if (cacheServices.IsSet("access_token"))
                        {
                            accesstoken = (string)cacheServices.Get("access_token");
                        }
                        else
                        {
                            var atvm = WeChatHepler.GetAccessTokenAsync(SettingsManager.WeiXin.AppId, SettingsManager.WeiXin.AppSecret).Result;
                            accesstoken = atvm.access_token;
                            cacheServices.Set("access_token", accesstoken, 120);
                        }
                        //_logger.Info("accesstoken:" + accesstoken);

                        var msg = $"您预约的直播视频[{video.Title}]即将在{video.StartDate:F}直播,At@{DateTime.Now}";
                        _logger.Info("消息内容:" + msg);
                        var openIds = res.Select(d => d.OpenId).ToArray();

                        if (openIds.Length == 1)
                        {
                            //  _logger.Info("accesstoken:单发");
                            var message = new SingleSendMessagesVM {
                                ToUser = openIds[0], MsgType = "text", Text = new Message {
                                    Content = msg
                                }
                            };

                            var json = JsonConvert.SerializeObject(message, Newtonsoft.Json.Formatting.Indented,
                                                                   new JsonSerializerSettings {
                                ContractResolver = new LowercaseContractResolver()
                            });

                            //Log("post:" + json);
                            HttpContent content = new StringContent(json);
                            content.Headers.ContentType = new MediaTypeHeaderValue("application/json");

                            var result = WeChatHepler.SingleSendMessagesAsync(accesstoken, content).Result;
                            if (result.ErrCode == 0)
                            {
                                foreach (var r in res)
                                {
                                    r.NoticedDate = DateTime.Now;
                                }
                                videoServices.Update(video);
                            }

                            _logger.Info($"单发结果[errcode:{result.ErrCode},errmsg:{result.ErrMsg}];消息主体:{json}");
                        }
                        else
                        {
                            // _logger.Info("accesstoken:群发");
                            var message = new BatchSendMessagesVM {
                                ToUser = openIds, MsgType = "text", Text = new Message {
                                    Content = msg
                                }
                            };
                            var json = JsonConvert.SerializeObject(message, Newtonsoft.Json.Formatting.Indented,
                                                                   new JsonSerializerSettings {
                                ContractResolver = new LowercaseContractResolver()
                            });

                            //Log("post:" + json);
                            HttpContent content = new StringContent(json);
                            content.Headers.ContentType = new MediaTypeHeaderValue("application/json");

                            var result = WeChatHepler.BatchSendMessagesAsync(accesstoken, content).Result;
                            if (result.ErrCode == 0)
                            {
                                foreach (var r in res)
                                {
                                    r.NoticedDate = DateTime.Now;
                                }
                                videoServices.Update(video);
                            }
                            _logger.Info($"群发结果[errcode:{result.ErrCode},errmsg:{result.ErrMsg}];消息主体:{json}");
                        }
                    }
                }
                catch (Exception ex)
                {
                    _logger.Fatal("发送失败:" + ex.Message);
                }
            }
        }
 public VideoController()
 {
     _VideoServices = new VideoServices(_unitOfWork);
 }
 public MotionController(IHttpClientFactory httpClientFactory, CompressService compressService, VideoServices videoServices)
 {
     this.httpClientFactory = httpClientFactory;
     this.compressService   = compressService;
     this.videoServices     = videoServices;
 }