Пример #1
0
 public MediaController(MediaService mediaService, MediaSettings mediaSettings, IMobSocialVideoProcessor videoProcessor, GeneralSettings generalSettings)
 {
     _mediaService = mediaService;
     _mediaSettings = mediaSettings;
     _videoProcessor = videoProcessor;
     _generalSettings = generalSettings;
 }
Пример #2
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="apiKey">The api key credential</param>
        public WistiaDataClient(string apiKey)
        {
            if (string.IsNullOrWhiteSpace(apiKey)) throw new ArgumentNullException(apiKey);

            Account = new AccountService(apiKey);
            Projects = new ProjectService(apiKey);
            Sharings = new SharingService(apiKey);
            Media = new MediaService(apiKey);
        }
Пример #3
0
        public void CanGetMediaForValidMediaType()
        {
            var type = MediaTypeUtility.GetTypeBuilder().CreateType();

            var contentMock = new Mock <IPublishedContent>();

            contentMock.Setup(m => m.Properties).Returns(new List <IPublishedProperty>());

            var service = new MediaService(new Mock <IUmbracoHelperWrapper>().Object);

            var media = service.GetMedia(contentMock.Object, type);

            Assert.IsNotNull(media);
        }
        /// <summary>
        /// Uploads an image.
        /// </summary>
        /// <param name="user">The AdWords user for which the image is uploaded.</param>
        /// <param name="url">The image URL.</param>
        /// <returns>The uploaded image.</returns>
        private static long UploadImage(AdWordsUser user, string url)
        {
            using (MediaService mediaService = (MediaService)user.GetService(
                       AdWordsService.v201806.MediaService)) {
                // Create the image.
                Image image = new Image();
                image.data = MediaUtilities.GetAssetDataFromUrl(url, user.Config);
                image.type = MediaMediaType.IMAGE;

                // Upload the image.
                Media[] result = mediaService.upload(new Media[] { image });
                return(result[0].mediaId);
            }
        }
Пример #5
0
        private async void Initialize()
        {
            this.AppVersion = SettingsService.LoadSetting <bool>(SettingsResources.UseStagingServer, false) ?
                              string.Format("{0} (staging)", AppService.GetAppVersion()) : AppService.GetAppVersion();

            this.MegaSdkVersion = AppService.GetMegaSDK_Version();

            // Initialize the PIN lock code setting
            SetField(ref this._isPinLockEnabled,
                     SettingsService.LoadSetting <bool>(SettingsResources.UserPinLockIsEnabled, false),
                     "IsMultiFactorAuthEnabled");

            // Do not set the property on initialize, because it fill fire the SetAutoCameraUploadStatus
            _cameraUploadsIsEnabled         = MediaService.GetAutoCameraUploadStatus();
            this.CameraUploadsIsEnabledText = _cameraUploadsIsEnabled ? UiResources.On : UiResources.Off;

            #if WINDOWS_PHONE_80
            this.ExportIsEnabled = SettingsService.LoadSetting <bool>(SettingsResources.ExportImagesToPhotoAlbum, false);
            #elif WINDOWS_PHONE_81
            this.AskDownloadLocationIsEnabled = SettingsService.LoadSetting <bool>(SettingsResources.AskDownloadLocationIsEnabled, false);
            this.StandardDownloadLocation     = SettingsService.LoadSetting <string>(
                SettingsResources.DefaultDownloadLocation, UiResources.DefaultDownloadLocation);
            #endif

            this.IsMultiFactorAuthAvailable = SdkService.MegaSdk.multiFactorAuthAvailable();
            if (this.IsMultiFactorAuthAvailable)
            {
                var mfaStatus = await AccountService.CheckMultiFactorAuthStatusAsync();

                switch (mfaStatus)
                {
                case MultiFactorAuthStatus.Enabled:
                    SetField(ref this._isMultiFactorAuthEnabled, true, "IsMultiFactorAuthEnabled");
                    break;

                case MultiFactorAuthStatus.Disabled:
                    SetField(ref this._isMultiFactorAuthEnabled, false, "IsMultiFactorAuthEnabled");
                    break;

                case MultiFactorAuthStatus.Unknown:
                    OnUiThread(() =>
                    {
                        new CustomMessageDialog(UiResources.UI_Warning, AppMessages.AM_MFA_CheckStatusFailed,
                                                App.AppInformation, MessageDialogButtons.Ok).ShowDialog();
                    });
                    break;
                }
            }
        }
Пример #6
0
        private void Initialize(string url)
        {
            Check.IsNotNullOrWhiteSpace(url, "ZabbixApi.url");

            _url        = url;
            _webClient  = new WebClient();
            _httpClient = new HttpClient();

            Actions            = new ActionService(this);
            Alerts             = new AlertService(this);
            ApiInfo            = new ApiInfoService(this);
            Applications       = new ApplicationService(this);
            DiscoveredHosts    = new DiscoveredHostService(this);
            DiscoveredServices = new DiscoveredServiceService(this);
            DiscoveryChecks    = new DiscoveryCheckService(this);
            DiscoveryRules     = new DiscoveryRuleService(this);
            Events             = new EventService(this);
            GraphItems         = new GraphItemService(this);
            GraphPrototypes    = new GraphPrototypeService(this);
            Graphs             = new GraphService(this);
            History            = new HistoryService(this);
            HostGroups         = new HostGroupService(this);
            HostInterfaces     = new HostInterfaceService(this);
            HostPrototypes     = new HostPrototypeService(this);
            Hosts               = new HostService(this);
            IconMaps            = new IconMapService(this);
            ITServiceService    = new ITServiceService(this);
            Images              = new ImageService(this);
            ItemPrototypes      = new ItemPrototypeService(this);
            Items               = new ItemService(this);
            LLDRules            = new LLDRuleService(this);
            Maintenance         = new MaintenanceService(this);
            Maps                = new MapService(this);
            Medias              = new MediaService(this);
            MediaTypes          = new MediaTypeService(this);
            Proxies             = new ProxyService(this);
            ScreenItems         = new ScreenItemService(this);
            Screens             = new ScreenService(this);
            Scripts             = new ScriptService(this);
            TemplateScreenItems = new TemplateScreenItemService(this);
            TemplateScreens     = new TemplateScreenService(this);
            Templates           = new TemplateService(this);
            TriggerPrototypes   = new TriggerPrototypeService(this);
            Triggers            = new TriggerService(this);
            UserGroups          = new UserGroupService(this);
            GlobalMacros        = new GlobalMacroService(this);
            HostMacros          = new HostMacroService(this);
            Users               = new UserService(this);
        }
Пример #7
0
        /// <summary>
        /// Uploads the image from the specified <paramref name="url"/>.
        /// </summary>
        /// <param name="user">The AdWords user.</param>
        /// <param name="url">The image URL.</param>
        /// <returns>ID of the uploaded image.</returns>
        private static long UploadImage(AdWordsUser user, String url)
        {
            using (MediaService mediaService =
                       (MediaService)user.GetService(AdWordsService.v201710.MediaService)) {
                // Create the image.
                Image image = new Image()
                {
                    data = MediaUtilities.GetAssetDataFromUrl(url, user.Config),
                    type = MediaMediaType.IMAGE
                };

                // Upload the image and return the ID.
                return(mediaService.upload(new Media[] { image })[0].mediaId);
            }
        }
Пример #8
0
        public IActionResult UploadBackground(UploadBackgroundViewModel background)
        {
            if (!ModelState.IsValid)
            {
                return(new BadResponseResult(ModelState));
            }
            var url = MediaService.UploadBackground(background.File, background.BackgroundType)
                      .FirstOrDefault(x => x.Size == BackgroundSizeType.Original)?.Url;

            return(url.IsNullOrEmpty()
        ? new ResponseResult((int)HttpStatusCode.NotModified)
        : new OkResponseResult(new UrlViewModel {
                Url = url
            }));
        }
Пример #9
0
 public FieldToComponent(Item i, ILogger l) : base(i, l)
 {
     ExistingDataNames   = GetItemField(i, "From What Field").Split(comSplitr, StringSplitOptions.RemoveEmptyEntries);
     Delimiter           = GetItemField(i, "Delimiter");
     Component           = GetItemField(i, "Component");
     Placeholder         = GetItemField(i, "Placeholder");
     DatasourcePath      = GetItemField(i, "Datasource Path");
     Device              = GetItemField(i, "Device");
     OverwriteExisting   = GetItemField(i, "Overwrite Existing") == "1";
     DatasourceFolder    = GetItemField(i, "Datasource Folder");
     Parameters          = GetItemField(i, "Parameters");
     IsSXA               = GetItemField(i, "Is SXA") == "1";
     PresentationService = new PresentationService(l);
     MediaService        = new MediaService(l);
 }
Пример #10
0
        public IActionResult UploadDefault(UploadDefaultViewModel avatar)
        {
            if (!ModelState.IsValid)
            {
                return(new BadResponseResult(ModelState));
            }

            var url = MediaService.UploadDefault(avatar.File).FirstOrDefault(x => x.Size == DefaultSizeType.Original)?.Url;

            return(url.IsNullOrEmpty()
        ? new ResponseResult((int)HttpStatusCode.NotModified)
        : new OkResponseResult(new UrlViewModel {
                Url = url
            }));
        }
Пример #11
0
        public void TestRemoveMediaObjectMediaNull()
        {
            // Arrange
            var service = new MediaService(
                null,
                null,
                null,
                null);

            // Act
            var result = service.RemoveMediaObject(null);

            // Assert
            Assert.False(result);
        }
        public void Export()
        {
            using (FolderBrowserDialog dialog = new FolderBrowserDialog())
            {
                if (dialog.ShowDialog() != DialogResult.OK || !MediaService.GetAudioFilePath(this.VideoModel.Url, out string path))
                {
                    return;
                }

                string name = Path.GetInvalidFileNameChars()
                              .Aggregate(this.VideoModel.Title, (current, invalidFileNameChar) => current.Replace(invalidFileNameChar, ' '));

                File.Copy(path, Path.Combine(dialog.SelectedPath, name + ".mp3"), true);
            }
        }
        public override void OnActionExecuting(HttpActionContext actionContext)
        {
            var mediaItem = (MediaItemSave)actionContext.ActionArguments["contentItem"];

            //We now need to validate that the user is allowed to be doing what they are doing.
            //Then if it is new, we need to lookup those permissions on the parent.
            IMedia contentToCheck = null;
            int    contentIdToCheck;

            switch (mediaItem.Action)
            {
            case ContentSaveAction.Save:
                contentToCheck   = mediaItem.PersistedContent;
                contentIdToCheck = contentToCheck.Id;
                break;

            case ContentSaveAction.SaveNew:
                contentToCheck = MediaService.GetById(mediaItem.ParentId);

                if (mediaItem.ParentId != Constants.System.Root)
                {
                    contentToCheck   = MediaService.GetById(mediaItem.ParentId);
                    contentIdToCheck = contentToCheck.Id;
                }
                else
                {
                    contentIdToCheck = mediaItem.ParentId;
                }

                break;

            default:
                //we don't support this for media
                actionContext.Response = actionContext.Request.CreateResponse(HttpStatusCode.NotFound);
                return;
            }

            if (MediaController.CheckPermissions(
                    actionContext.Request.Properties,
                    Security.CurrentUser,
                    MediaService,
                    EntityService,
                    contentIdToCheck,
                    contentToCheck) == false)
            {
                throw new HttpResponseException(actionContext.Request.CreateUserNoAccessResponse());
            }
        }
Пример #14
0
        public void TestUpdateMediaCollectionFileNamesNull()
        {
            // Arrange
            var service = new MediaService(
                null,
                null,
                null, null);

            var entity = new Listing();

            // Act
            service.UpdateMediaCollection(null, entity);

            // Assert
            Assert.Empty(entity.Media);
        }
        public ProfilViewModelUtilisateur(INavigation navigation)
        {
            _navigation    = navigation;
            _membre        = new Membre();
            _mediaServices = new MediaService();

            _validatorProfil = new ValideurProfilUtilisateur();


            SelectImageCommand      = new Command(async() => await SelectImageCommandProfil());
            ValiderProfilCommand    = new Command(async() => await EnregistrementProfil());
            AllerAmiseAjourPassword = new Command(async() => await AllerAmiseAjour());
            // AjoutImageProfil = new Command();

            FetchUserConnexionDetails();
        }
Пример #16
0
 /// <summary>
 /// Uploads an image to the server.
 /// </summary>
 /// <param name="user">The AdWords user.</param>
 /// <param name="url">The URL of image to upload.</param>
 /// <returns>The created image.</returns>
 private static Media UploadImage(AdWordsUser user, string url)
 {
     using (MediaService mediaService =
                (MediaService)user.GetService(AdWordsService.v201802.MediaService))
     {
         Image image = new Image
         {
             data = MediaUtilities.GetAssetDataFromUrl(url, user.Config),
             type = MediaMediaType.IMAGE
         };
         return(mediaService.upload(new Media[]
         {
             image
         })[0]);
     }
 }
Пример #17
0
        /// <summary>
        /// Our site wide search action method
        /// </summary>
        public JsonResult GetVimeoData(string vimeoUrl)
        {
            if (!vimeoUrl.StartsWith("http://www.vimeo.com/") && !vimeoUrl.StartsWith("http://vimeo.com/"))
            {
                throw new Exception("Not a valid vimeo url");
            }

            //http://www.vimeo.com/20278551?ab = /20278551
            var videoUriWithoutQuery = new Uri(vimeoUrl).AbsolutePath;

            var videoID = videoUriWithoutQuery.Replace("/", "");

            var vimeoData = new MediaService().GetVimeoVideoData(videoID);

            return(Json(vimeoData));
        }
Пример #18
0
    public override void OnCreate()
    {
        base.OnCreate();

        _mediaService = new MediaService();
        _mediaService.OnServiceChanged += mediaService_OnServiceChanged;

        // --- Register this as a listener with the underlying service.
        var sensorManager = GetSystemService(SensorService) as Android.Hardware.SensorManager;
        var sensor        = sensorManager.GetDefaultSensor(Android.Hardware.SensorType.Accelerometer);

        _shakeDetector = new ShakeDetector(this);
        SetServiceState(true);

        sensorManager.RegisterListener(_shakeDetector, sensor, Android.Hardware.SensorDelay.Normal);
        _preferences = Application.Context.GetSharedPreferences(ToolsFragment.APP_SETTINGS_NAME, FileCreationMode.Private);
    }
Пример #19
0
        public void CanGetMediaIdByConvention()
        {
            const int id = 123;

            var publishedContentMock = new Mock <IPublishedContent>();

            publishedContentMock.Setup(m => m.Id).Returns(id);
            publishedContentMock.Setup(m => m.Properties).Returns(new IPublishedProperty[] { });

            var umbracoHelperWrapperMock = new Mock <IUmbracoHelperWrapper>();

            umbracoHelperWrapperMock.Setup(m => m.TypedMedia(id)).Returns(publishedContentMock.Object);

            var media = new MediaService(umbracoHelperWrapperMock.Object).GetMedia <Models.MediaType>(id);

            Assert.AreEqual(id, media.Id);
        }
Пример #20
0
        public MonitoringWorker(AzureMediaService mediaService, List <AzureDataConfig> connectionList)
        {
            connectionList.ForEach(connection =>
                                   Trace.TraceInformation("database:{0}  user:{1}, InitialCatalog:{2}", connection.AzureServer, connection.UserName, connection.InitialCatalog)
                                   );
            MediaService    = mediaService;
            _connectionList = connectionList;
            _cache          = MdCache.Instance;

            Account = new MediaService
            {
                Name       = mediaService.Config.AccountName,
                Id         = mediaService.Config.Id,
                Datacenter = mediaService.Config?.MetaData.Location,
                Origins    = EntityFactory.BuildOriginListFromStreamingEndpoints(mediaService.CloudContext.StreamingEndpoints)
            };
        }
Пример #21
0
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="user">The AdWords user.</param>
        public void Run(AdWordsUser user)
        {
            using (MediaService mediaService =
                       (MediaService)user.GetService(AdWordsService.v201809.MediaService))
            {
                try
                {
                    // Create HTML5 media.
                    byte[] html5Zip =
                        MediaUtilities.GetAssetDataFromUrl("https://goo.gl/9Y7qI2", user.Config);
                    // Create a media bundle containing the zip file with all the HTML5 components.
                    Media[] mediaBundle = new Media[]
                    {
                        new MediaBundle()
                        {
                            data = html5Zip,
                            type = MediaMediaType.MEDIA_BUNDLE
                        }
                    };

                    // Upload HTML5 zip.
                    mediaBundle = mediaService.upload(mediaBundle);

                    // Display HTML5 zip.
                    if (mediaBundle != null && mediaBundle.Length > 0)
                    {
                        Media newBundle = mediaBundle[0];
                        Dictionary <MediaSize, Dimensions>
                        dimensions = newBundle.dimensions.ToDict();
                        Console.WriteLine(
                            "HTML5 media with id \"{0}\", dimensions \"{1}x{2}\", and MIME type " +
                            "\"{3}\" was uploaded.", newBundle.mediaId,
                            dimensions[MediaSize.FULL].width, dimensions[MediaSize.FULL].height,
                            newBundle.mimeType);
                    }
                    else
                    {
                        Console.WriteLine("No HTML5 zip was uploaded.");
                    }
                }
                catch (Exception e)
                {
                    throw new System.ApplicationException("Failed to upload HTML5 zip file.", e);
                }
            }
        }
Пример #22
0
        private void TreeViewAzureSub_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (e.Node.Level == 1)
            {
                List <MediaService> accounts = allAMSAccountsPerSub[(string)e.Node.Parent.Tag];
                MediaService        account  = accounts.Where(a => a.Id == (string)e.Node.Tag).FirstOrDefault();

                // let's display account info
                DisplayInfoAccount(account);
                selectedAccount    = account;
                buttonNext.Enabled = true;
            }
            else
            {
                ClearDisplayInfoAccount();
                buttonNext.Enabled = false;
            }
        }
Пример #23
0
        protected override ContentMetadataRepresentation GetMetadataForItem(int id)
        {
            var found = MediaService.GetById(id);

            if (found == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            var result = new ContentMetadataRepresentation(LinkTemplate, id)
            {
                Fields         = GetDefaultFieldMetaData(),
                Properties     = Mapper.Map <IDictionary <string, ContentPropertyInfo> >(found),
                CreateTemplate = Mapper.Map <ContentTemplate>(found)
            };

            return(result);
        }
Пример #24
0
        public static PipelineStatus Map(MediaService mediaService, MediaChannel mediaChannel)
        {
            var program = mediaService.Programs.Where(x => x.ChannelId == mediaChannel.Id).FirstOrDefault();

            var pipelineStatus = new Data.PipelineStatus();

            pipelineStatus.Id = mediaChannel.Id;

            var status = new Data.Status();

            status.ChannelStatus = (int)mediaChannel.Health;
            status.ProgramStatus = (int)program.Health;
            status.OriginStatus  = -1; //TODO: GET THIS VIA THE NEW CONFIG SETTING;

            pipelineStatus.Status = status;

            return(pipelineStatus);
        }
Пример #25
0
        public ActionResult AddMedia(FormCollection form)
        {
            if (Request.Files.Count == 0)
            {
                //Request.Files.Count 文件数为0上传不成功
                return(Json("文件数为0上传不成功", JsonRequestBehavior.AllowGet));
            }

            var file = Request.Files["Media"];

            if (file.ContentLength == 0)
            {
                //文件大小(以字节为单位)为0时,做一些操作
                return(Json("文件大小(以字节为单位)为0", JsonRequestBehavior.AllowGet));
            }
            else
            {
                HttpPostedFileBase files    = Request.Files[0];
                string             fileName = (!string.IsNullOrEmpty(form["FileName"])) ? form["FileName"]: files.FileName;
                string             format   = files.FileName.Substring(files.FileName.LastIndexOf('.'));
                if (fileName.IndexOf(format) == -1)
                {
                    fileName += format;
                }
                //文件大小不为0
                string url = Server.MapPath("/Upload/") + fileName;
                files.SaveAs(url);
                MediaService ser = new MediaService(WXAPP.AppId, WXAPP.AppSecret);
                JObject      jo  = ser.PostImage(fileName); //返回一个mediaid和url
                if (jo != null)                             //新增成功
                {
                    var r = new WX_MediaManager().Add(new WX_Media()
                    {
                        AppId        = WXAPP.AppId,
                        MediaId      = jo["media_id"].ToString(),
                        MediaName    = fileName,
                        MediaType    = "image",
                        MediaContent = jo["url"].ToString(),
                        UploadTime   = DateTime.Now,
                    });
                }
            }
            return(Redirect("Index"));
        }
Пример #26
0
        public SettingsViewModel(MegaSDK megaSdk, AppInformation appInformation)
            : base(megaSdk, appInformation)
        {
            this.AppVersion              = AppService.GetAppVersion();
            this.MegaSdkVersion          = AppService.GetMegaSDK_Version();
            this.ShareRecoveryKeyCommand = new DelegateCommand(ShareRecoveryKey);
            this.CopyRecoveryKeyCommand  = new DelegateCommand(CopyRecoveryKey);
            this.ChangePinLockCommand    = new DelegateCommand(ChangePinLock);
            this.ViewRecoveryKeyCommand  = new DelegateCommand(ViewRecoveryKey);

            #if WINDOWS_PHONE_80
            this.SelectDownloadLocationCommand = null;
            #elif WINDOWS_PHONE_81
            this.SelectDownloadLocationCommand = new DelegateCommand(SelectDownloadLocation);
            #endif

            this.MegaSdkCommand                  = new DelegateCommand(NavigateToMegaSdk);
            this.GoedWareCommand                 = new DelegateCommand(NavigateToGoedWare);
            this.TermsOfServiceCommand           = new DelegateCommand(NavigateToTermsOfService);
            this.PrivacyPolicyCommand            = new DelegateCommand(NavigateToPrivacyPolicy);
            this.CopyrightCommand                = new DelegateCommand(NavigateToCopyright);
            this.TakedownGuidanceCommand         = new DelegateCommand(NavigateToTakedownGuidance);
            this.GeneralCommand                  = new DelegateCommand(NavigateToGeneral);
            this.DataProtectionRegulationCommand =
                new DelegateCommand(NavigateToDataProtectionRegulation);

            this.PinLockIsEnabled = SettingsService.LoadSetting <bool>(SettingsResources.UserPinLockIsEnabled, false);

            // Do not set the property on initialize, because it fill fire the SetAutoCameraUploadStatus
            _cameraUploadsIsEnabled         = MediaService.GetAutoCameraUploadStatus();
            this.CameraUploadsIsEnabledText = _cameraUploadsIsEnabled ? UiResources.On : UiResources.Off;

            #if WINDOWS_PHONE_80
            this.ExportIsEnabled = SettingsService.LoadSetting <bool>(SettingsResources.ExportImagesToPhotoAlbum, false);
            #elif WINDOWS_PHONE_81
            this.AskDownloadLocationIsEnabled = SettingsService.LoadSetting <bool>(SettingsResources.AskDownloadLocationIsEnabled, false);
            this.StandardDownloadLocation     = SettingsService.LoadSetting <string>(
                SettingsResources.DefaultDownloadLocation, UiResources.DefaultDownloadLocation);
            #endif

            UpdateUserData();

            InitializeMenu(HamburgerMenuItemType.Settings);
        }
Пример #27
0
        protected virtual string GetSearchEntryImage(SearchResultEntry entry)
        {
            string imageResult = null, mimeTypeResult = null;

            foreach (var el in entry.FieldValues)
            {
                if (el.Key.Contains("Image"))
                {
                    imageResult = MediaService.GetMediaUrl(el.Value.ToString());
                    break;
                }
                //implementing the same logic, remembering the first mimetype, but keeping search for image key
                if (mimeTypeResult == null && el.Key.Contains("MimeType") && el.Value.ToString().StartsWith("image/"))
                {
                    mimeTypeResult = entry.Url;
                }
            }
            return(imageResult ?? mimeTypeResult);
        }
Пример #28
0
        public ActionResult Upload([Bind(Include = "Title, Description, IsPrivate, Category")] Media mediaFile,
                                   HttpPostedFileBase file)
        {
            var isFileValid = (file != null && file.ContentLength > 0);

            mediaFile.ApplicationUserId = User.Identity.GetUserId();

            if (!ModelState.IsValid || !isFileValid || !ServerParams.CategoriesList.List.Contains(mediaFile.Category))
            {
                var ms = ModelState;
                Response.StatusCode = 400;
                var errors = ModelErrorsToDictionary(ModelState);
                if (!isFileValid)
                {
                    errors.Add("File", "File not supported.");
                }

                return(Json(errors));
            }

            mediaFile.IsBeingConverted = true;
            db.Media.Add(mediaFile);
            db.SaveChanges();

            var dir = Server.MapPath("~/MediaData/Videos/" + mediaFile.Id);

            // todo: check if dir exists
            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }

            var fileName = Path.GetFileName(file.FileName);
            var path     = Path.Combine(dir, fileName);

            file.SaveAs(path);

            MediaService.ConvertVideo(fileName, mediaFile.Id);

            ViewBag.Info        = "Your video was successfully uploaded";
            Response.StatusCode = 200;
            return(Json("Success"));
        }
        public override void Run(string[] parameters)
        {
            var resourceGroup            = parameters[0];
            var mediaServicesAccountName = parameters[1];
            var storageAccountId         = parameters[2];

            var mediaServicesManagementClient = CreateMediaServicesManagementClient();

            var account = mediaServicesManagementClient.MediaService.Get(resourceGroup, mediaServicesAccountName);

            var updatedStorageAccounts = account.StorageAccounts.Where(x => string.Compare(x.Id, storageAccountId, StringComparison.OrdinalIgnoreCase) != 0).ToArray();

            var updatedAccount = new MediaService
            {
                StorageAccounts = updatedStorageAccounts
            };

            mediaServicesManagementClient.MediaService.Update(resourceGroup, mediaServicesAccountName, updatedAccount);
        }
Пример #30
0
        public async Task Test1()
        {
            var options = new WebOptions {
                MediaStoragePath = "./app_data/media"
            };

            var subs = new Subtitles {
                Id = "0c86a6a1f91a3f806095b165b7df6673.mp4", Lines = new[] { "1", "00:00:00,100 --> 00:00:05,000", "Welkom in deze wereld!" }
            };
            var mockRedis = new Mock <IConnectionMultiplexer>();
            var modkDb    = new Mock <IDatabase>();

            modkDb.Setup(s => s.StringSetAsync(It.IsAny <RedisKey>(), It.IsAny <RedisValue>(), It.IsAny <TimeSpan>(),
                                               It.IsAny <When>(), It.IsAny <CommandFlags>()));
            modkDb.Setup(s => s.StringGetAsync(It.IsAny <RedisKey>(), It.IsAny <CommandFlags>())).ReturnsAsync((RedisValue)10);
            mockRedis.Setup(m => m.GetDatabase(-1, null)).Returns(modkDb.Object);
            var mediaService = new MediaService(Options.Create(options), Options.Create(new FormOptions()), new NullLogger <MediaService>(), mockRedis.Object);
            var str          = mediaService.AddSubTitles(subs, CancellationToken.None);
        }
 private void FillPlayList()
 {
     try
     {
         Playlist.Clear();
         var mediaService = new MediaService();
         foreach (string format in _formats)
         {
             foreach (var filePath in Directory.GetFiles(DirectoryDialog.SelectedPath, format, SearchOption.AllDirectories))
             {
                 Playlist.Add(mediaService.GetMedia(filePath));
             }
         }
     }
     catch (Exception ex)
     {
         System.Windows.Forms.MessageBox.Show(ex.Message, "Filmst");
     }
 }
Пример #32
0
 public BatchController(
     IOptions <ManagerConfiguration> managerConfiguration,
     FileService fileService,
     PathService pathService,
     ModuleConfigurator moduleConfigurator,
     TranscriptService transcriptService,
     MediaService mediaService,
     ClipService clipService,
     FolderService folderService)
 {
     this.FileService          = fileService;
     this.PathService          = pathService;
     this.ManagerConfiguration = managerConfiguration;
     this.ModuleConfigurator   = moduleConfigurator;
     this.TranscriptService    = transcriptService;
     this.MediaService         = mediaService;
     this.ClipService          = clipService;
     this.FolderService        = folderService;
 }
Пример #33
0
 protected override void _Initialize(Key key)
 {
     base._Initialize(key);
     m_mediaService      = new MediaService(this);
 }