当前位置: 首页>>代码示例>>C#>>正文


C# MediaFile类代码示例

本文整理汇总了C#中MediaFile的典型用法代码示例。如果您正苦于以下问题:C# MediaFile类的具体用法?C# MediaFile怎么用?C# MediaFile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MediaFile类属于命名空间,在下文中一共展示了MediaFile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GenerateImage

        protected override Image GenerateImage(MediaFile videoFile, ThumbnailGenerationOptions options)
        {
            var baseImage = _thumbnailGenerator.Generate(videoFile, options).Image;

            var sizedImage = ResizeImage(baseImage, options.ImageSize.Width, options.ImageSize.Height);
            return sizedImage;
        }
开发者ID:stusherwin,项目名称:MediaTagger,代码行数:7,代码来源:SizedThumbnailGenerator.cs

示例2: FixOrientationAsync

		async public Task<bool> FixOrientationAsync(MediaFile file)
		{
			if (file == null)
				return false;
			try
			{

				var filePath = file.Path;
				var orientation = GetRotation(filePath);

				if (!orientation.HasValue)
					return false;

				Bitmap bmp = RotateImage(filePath, orientation.Value);
				var quality = 90;

				using (var stream = File.Open(filePath, FileMode.OpenOrCreate))
					await bmp.CompressAsync(Bitmap.CompressFormat.Png, quality, stream);

				bmp.Recycle();

				return true;
			}
			catch (Exception ex)
			{                               
				//ex.Report(); //Extension method for Xamarin.Insights
				return false;
			}
		}
开发者ID:praveenmohanmm,项目名称:PurposeColor_Bkp_Code,代码行数:29,代码来源:AndroidMediaView.cs

示例3: Segment

        public IEnumerable<MediaSegment> Segment(FileInfo file, long fileId)
        {
            var source = new MediaFile(file.FullName);
            using (var engine = new Engine())
            {
                engine.GetMetadata(source);
                var progressMs = 0.0;
                while (progressMs < source.Metadata.Duration.TotalMilliseconds)
                {
                    var options = new ConversionOptions();
                    var endMs = Math.Min(progressMs + _segmentLengthMs, source.Metadata.Duration.TotalMilliseconds);

                    options.CutMedia(TimeSpan.FromMilliseconds(progressMs),
                        TimeSpan.FromMilliseconds(endMs));

                    var outputFile = Path.Combine(file.DirectoryName,
                        string.Format("{0}_audio_{1}ms.wav", file.Name, progressMs));

                    engine.Convert(source, new MediaFile(outputFile), options);
                    yield return new MediaSegment
                    {
                        FileId = fileId,
                        File = new FileInfo(outputFile),
                        OffsetMs = progressMs,
                        DurationMs = endMs - progressMs
                    };
                    progressMs = endMs;
                }
            }
        }
开发者ID:kaisermatt,项目名称:funwithspeech,代码行数:30,代码来源:SegmenterService.cs

示例4: PickPhotoAsync

        public async Task<IMediaFile> PickPhotoAsync()
        {
            Debug.WriteLine("PickPhotoAsync: starting");
            // setup a task to get the results back from the delegate
            var mediaInfoTask = new TaskCompletionSource<NSDictionary>();

            // setup a UI Picker to show photos
            var picker = new UIImagePickerController();
            picker.SourceType = UIImagePickerControllerSourceType.PhotoLibrary;
            picker.MediaTypes = new string[] { UTType.Image };
            picker.AllowsEditing = false;
            picker.Delegate = new MediaDelegate { InfoTask = mediaInfoTask };
            // iPad should display the picker in a popover
            if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad)
                picker.ModalInPopover = true;
            var vc = GetViewController();
            Debug.WriteLine("PickPhotoAsync: displaying photo picker");
            vc.PresentViewController(picker, true, null);
            // wait to get the results back
            Debug.WriteLine("PickPhotoAsync: waiting for selected photo");
            var info = await mediaInfoTask.Task;
            var assetUrl = info[UIImagePickerController.ReferenceUrl] as NSUrl;
            Debug.WriteLine("PickPhotoAsync: photo selected {0}", assetUrl);
            var mediaFile = new MediaFile {Path = assetUrl.ToString()};
            Debug.WriteLine("PickPhotoAsync: returning created media file");
            return mediaFile;
        }
开发者ID:JC-Chris,项目名称:XFExtensions,代码行数:27,代码来源:MediaImplementation.cs

示例5: ConvertMediaFile

 private void ConvertMediaFile(MediaFile mediaFile, FileToSyncItemConfiguration path)
 {
     if (File.Exists(path.Destination.FullPath + PathUtils.Extension))
     {
         SyncItem parent = SyncItemProvider.GetSyncItem(path.Destination.FullPath + PathUtils.Extension);
         string name = String.IsNullOrEmpty(Path.GetFileNameWithoutExtension(mediaFile.Name))
             ? mediaFile.Name
             : Path.GetFileNameWithoutExtension(mediaFile.Name);
         string syncItemPath = Path.Combine(path.Destination.FullPath, name + PathUtils.Extension);
         if (File.Exists(syncItemPath))
         {
             SyncItem syncItem = SyncItemProvider.GetSyncItem(syncItemPath);
             if (mediaFile.Blob != syncItem.SharedValues[FileTemplateFields.Blob.FieldId])
             {
                 syncItem.AttachMediaFile(new FileInfo(mediaFile.FilePath));
                 syncItem = _serializationManager.UpdateStatistics(syncItem);
                 SyncItemProvider.SaveSyncItem(syncItem, syncItemPath);
             }
         }
         else
         {
             SyncItem item = _serializationManager.CreateSyncMediaItem(parent.ItemPath, path.Destination.Database, parent.ID, mediaFile.FilePath);
             SyncItemProvider.SaveSyncItem(item, syncItemPath);
         }
     }
 }
开发者ID:alan-null,项目名称:MediaLibrarySynchronizer,代码行数:26,代码来源:FileToSyncItemConverter.cs

示例6: FilePath

        // Returns the value of the FilePath for a given item
        // ** Example **
        // Given: MediaFile: Artist: Artist1, Album: Album1, Genre: Genre1, FileType: MP3, FileName: SongTitle.mp3
        // Order: FileType -> Genre -> Artist -> Album
        // (External usage) Base Directory: C:/Music
        // Returns: MP3/Genre1/Artist1/Album1/
        // Helps Create: C:/Music/MP3/Genre1/Artist1/Album1/SongTitle.mp3
        public string FilePath( MediaFile mf )
        {
            string filePath = "";

            foreach ( string folder in folderStructure.FolderCategories )
            {
                if ( folder == "Artist" )
                {
                    filePath += mf.Artist + @"/";
                }
                if ( folder == "Album" )
                {
                    filePath += mf.Album + @"/";
                }
                if ( folder == "FileType" )
                {
                    filePath += mf.FileType.Substring( 1, mf.FileType.Length - 1 ).ToUpper( ) + @"/";
                }
                if ( folder == "Genre" )
                {
                    filePath += mf.Genre + @"/";
                }
            }

            return filePath;
        }
开发者ID:kamalm87,项目名称:TagLookup,代码行数:33,代码来源:FileMover.cs

示例7: GetVideoInfo

        public static Dictionary<string, string> GetVideoInfo(string fileName)
        {
            var dic = new Dictionary<string, string>();
            var mediaFile = new MediaFile(fileName);

            dic.Add(VideoInfoConstants.FileName, mediaFile.Name);
            dic.Add(VideoInfoConstants.Format, mediaFile.General.Format);
            dic.Add(VideoInfoConstants.Duration, mediaFile.General.DurationString);
            dic.Add(VideoInfoConstants.Bitrate, mediaFile.General.Bitrate.ToInvariantString());

            if (mediaFile.Audio.Count > 0)
            {

                dic.Add(VideoInfoConstants.AudioFormat, mediaFile.Audio[0].Format);
                dic.Add(VideoInfoConstants.AudioBitrate, mediaFile.Audio[0].Bitrate.ToInvariantString());
                dic.Add(VideoInfoConstants.AudioChannels, mediaFile.Audio[0].Channels.ToInvariantString());
                dic.Add(VideoInfoConstants.AudioSamplingRate, mediaFile.Audio[0].SamplingRate.ToInvariantString());
            }

            if (mediaFile.Video.Count > 0)
            {

                dic.Add(VideoInfoConstants.VideoFormat, mediaFile.Video[0].Format);
                dic.Add(VideoInfoConstants.VideoBitrate, mediaFile.Video[0].Bitrate.ToInvariantString());
                dic.Add(VideoInfoConstants.VideoFrameRate, mediaFile.Video[0].FrameRate.ToInvariantString());
                dic.Add(VideoInfoConstants.VideoFrameSize, mediaFile.Video[0].FrameSize);
            }

            return dic;
        }
开发者ID:ashish-antil,项目名称:Products,代码行数:30,代码来源:VideoUtils.cs

示例8: CreateViewable

        public ObservableCollection<MediaFile> CreateViewable( string folderPath )
        {
            if ( !Directory.Exists( folderPath ) ) return null;

            fileLoader.ReadFolder( folderPath );

            foreach ( string file in fileLoader.Files )
            {
                try
                {
                    var mf = new MediaFile( TagLib.File.Create( file ) );
                    fullFilePathToMediaFile.Add( file, mf );
                    int lastSlashOffset = file.LastIndexOf( "\\" ) + 1;
                    string partialFile = file.Substring( lastSlashOffset );
                    partialFilePathToMediaFile.Add( partialFile, mf );
                    ocMediaFiles.Add( mf );
                }
                catch ( Exception ex )
                {
                    exceptionList.Add( new Tuple<string, string>( ex.Message + System.Environment.NewLine + ex.StackTrace, file ) );
                }
            }

            return ocMediaFiles;
        }
开发者ID:kamalm87,项目名称:TagLookup,代码行数:25,代码来源:MediaFileCollection.cs

示例9: MenuOpenFile_OnClick

      /// <summary>
      /// Open file for playing
      /// </summary>
      /// <param name="sender"></param>
      /// <param name="e"></param>
      private void MenuOpenFile_OnClick(object sender, RoutedEventArgs e) {
         try {
            var objDialog = new OpenFileDialog() {
               Filter = "Media files| *.mp4; *.avi; *.mp3; *.wav; *.pl"
            };
            bool? result = objDialog.ShowDialog();
            if(result == true) {
               var objFileInfo = new FileInfo(objDialog.FileName);
               //rewrite current play list
               _PlayList = new PlayList();

               //if we opened playlist
               if(objFileInfo.Extension == ".pl") {
                  _PlayList.Open(objDialog.FileName);
                  UpdatePlayListView();
               }
               else {
                  //if we opened standart media file
                  var objMediaFile = new MediaFile(objFileInfo);
                  _PlayList.MediaFiles.Add(objMediaFile);
                  ListBoxPlayList.Items.Add(objMediaFile);
               }
               ListBoxPlayList.SelectedIndex = 0;
               ListBoxPlayList_OnMouseDoubleClick(sender, null);
            }
         }
         catch(Exception ex) {
            MessageBox.Show(ex.Message);
         }
      }
开发者ID:Feliasfogg,项目名称:HomeWorks,代码行数:35,代码来源:MainWindow.xaml.cs

示例10: LoadButton_Click

        private void LoadButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                OpenFileDialog openFile = new OpenFileDialog
                {
                    Filter = "Video files (*.mp4)|*.mp4",
                    FilterIndex = 1,
                    RestoreDirectory = true
                };

                if (openFile.ShowDialog() == true)
                {
                    Screen.Source = new Uri(openFile.FileName);
                    Screen.LoadedBehavior = MediaState.Pause;

                    inputFile = new MediaFile {Filename = openFile.FileName};
                }

                _firstPlay = true;
            }
            catch (Exception)
            {
                MessageBox.Show("Failed load video");
            }
        }
开发者ID:SeriousCoder,项目名称:Terkom-sTask,代码行数:26,代码来源:MainWindow.xaml.cs

示例11: UploadMediaAsync

        public async Task<MediaFile> UploadMediaAsync(MediaUpload upload)
        {
            var blobId = await GetNewBlobIdAsync(upload.ContentType);
            var url = string.Format("{0}/content/{1}", BaseApiUrl, blobId);

            using (var client = new HttpClient())
            {
                var response = await client.PostAsync(url, upload.Content);
                if (!response.IsSuccessStatusCode) return null;
            }

            var media = new MediaFile
            {
                BlobId = blobId,
                ContentSize = upload.ContentSize,
                ContentType = upload.ContentType,
                Uploaded = DateTime.UtcNow
            };

            var inserted = _mediaRepository.Insert(media);
            _unit.Commit();

            Log.InfoFormat("Uploaded media to FooCDN.  Id={0} BlobId={1} ContentSize={2} ContentType={3} StorageType={4}", media.Id, media.BlobId, media.ContentSize, media.ContentType, media.StorageType);

            return inserted;
        }
开发者ID:ryanerdmann,项目名称:angora,代码行数:26,代码来源:FooCdnMediaService.cs

示例12: Can_CutVideo

        public void Can_CutVideo()
        {
            string filePath = @"{0}\Cut_Video_Test.mp4";
            string outputPath = string.Format(filePath, Path.GetDirectoryName(_outputFilePath));

            var inputFile = new MediaFile { Filename = _inputFilePath };
            var outputFile = new MediaFile { Filename = outputPath };

            using (var engine = new Engine())
            {
                engine.ConvertProgressEvent += engine_ConvertProgressEvent;
                engine.ConversionCompleteEvent += engine_ConversionCompleteEvent;

                engine.GetMetadata(inputFile);

                ConversionOptions options = new ConversionOptions();
                options.CutMedia(TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(25));

                engine.Convert(inputFile, outputFile, options);
                engine.GetMetadata(outputFile);
            }
            
            Assert.That(File.Exists(outputPath));
            // Input file is 33 seconds long, seeking to the 30th second and then 
            // attempting to cut another 25 seconds isn't possible as there's only 3 seconds
            // of content length, so instead the library cuts the maximumum possible.
        }
开发者ID:AdmiralCurtiss,项目名称:MediaToolkit,代码行数:27,代码来源:ConvertTest.cs

示例13: GenerateKey

 protected override string GenerateKey(MediaFile videoFile, ThumbnailGenerationOptions options)
 {
     return string.Format("{0}_{1}_{2}",
         videoFile.Id,
         options.PointInTime.ResolveAgainst(videoFile.Duration).ToTicksString(),
         options.ImageSize);
 }
开发者ID:stusherwin,项目名称:MediaTagger,代码行数:7,代码来源:SizedThumbnailGenerator.cs

示例14: Recognise

 async Task Recognise (MediaFile result)
 {
     if (result.Source == null)
         return;
     try {
         activityIndicator.IsRunning = true;
         if (!_tesseract.Initialized) {
             var initialised = await _tesseract.Init ("eng");
             if (!initialised)
                 return;
         }
         if (!await _tesseract.SetImage (result.Source))
             return;
     } catch (Exception ex) {
         DisplayAlert ("Error", ex.Message, "Cancel");
     } finally {
         activityIndicator.IsRunning = false;
     }
     TextLabel.Text = _tesseract.Text;
     var words = _tesseract.Results (PageIteratorLevel.Word);
     var symbols = _tesseract.Results (PageIteratorLevel.Symbol);
     var blocks = _tesseract.Results (PageIteratorLevel.Block);
     var paragraphs = _tesseract.Results (PageIteratorLevel.Paragraph);
     var lines = _tesseract.Results (PageIteratorLevel.Textline);
 }
开发者ID:Tolulope,项目名称:Tesseract.Xamarin,代码行数:25,代码来源:MainPage.xaml.cs

示例15: FileController_UpdateSEO_ShouldReturnChangesSaved

        public void FileController_UpdateSEO_ShouldReturnChangesSaved()
        {
            FileController fileController = GetFileController();

            var mediaFile = new MediaFile();
            fileController.UpdateSEO(mediaFile, "test", "test").Should().Be("Changes saved");
        }
开发者ID:neozhu,项目名称:MrCMS,代码行数:7,代码来源:FileControllerTests.cs


注:本文中的MediaFile类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。