• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# MediaFile类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: ExtractSeasonAndEpisode

        /// <summary>
        /// Extracts season and episode number by using some regexes specified in patterns
        /// </summary>
        /// <param name="ie">Candidate which should be processed</param>
        /// <param name="patterns">Patterns to be used for recognition, supply these for speed reasons?</param>
        public static void ExtractSeasonAndEpisode(MediaFile ie, string[] patterns)
        {
            string strSeason = "";
            string strEpisode = "";
            Match m = null;
            int episode = -1;
            int season = -1;
            log.Debug("Extracting season and episode from " + ie.FilePath + Path.DirectorySeparatorChar + ie.Filename);
            //[MOVIES_TAGS_TO_REMOVE_LIST_KEY] and (CRCXXXXX) are removed for recognition, since they might produce false positives
            string cleanedname = Regex.Replace(ie.Filename, "\\[.*?\\]|\\(.{8}\\)", "");
            foreach (string pattern in patterns) {
                //Try to match. If it works, get the season and the episode from the match
                m = Regex.Match(cleanedname, pattern, RegexOptions.IgnoreCase | RegexOptions.RightToLeft);
                if (m.Success) {
                    log.Debug("This pattern produced a match: " + pattern);
                    strSeason = "";
                    strEpisode = "";
                    //ignore numbers like 2063, chance is higher they're a year than a valid season/ep combination
                    if (Int32.Parse(m.Groups["Season"].Value + m.Groups["Episode"].Value) > 2000 && (m.Groups["Season"].Value + m.Groups["Episode"].Value).StartsWith("20")) {
                        continue;
                    }
                    try {
                        strSeason = Int32.Parse(m.Groups["Season"].Value).ToString();
                    } catch (FormatException) {
                    }
                    try {
                        strEpisode = Int32.Parse(m.Groups["Episode"].Value).ToString();
                    } catch (FormatException) {
                    }
                    //Fix for .0216. notation for example, 4 numbers should always be recognized as %S%S%E%E (IF THEY ARENT A YEAR!)
                    if (strEpisode.Length == 3 && strSeason.Length == 1) {
                        strSeason += strEpisode[0];
                        strEpisode = strEpisode.Substring(1);
                        if (strSeason[0] == '0') {
                            strSeason = strSeason.Substring(1);
                        }
                    }

                    try {
                        episode = Int32.Parse(strEpisode);
                    } catch {
                        log.Debug("Cannot parse found episode: " + strEpisode);
                    }
                    try {
                        season = Int32.Parse(strSeason);
                    } catch {
                        log.Debug("Cannot parse found season: " + strSeason);
                    }

                    if ((ie.Filename.ToLower().Contains("720p") && season == 7 && episode == 20) | (ie.Filename.ToLower().Contains("1080p") && season == 10 && episode == 80)) {
                        season = -1;
                        episode = -1;
                        continue;
                    }
                    ie.SeasonNr = season;
                    ie.EpisodeNr = episode;
                    return;
                }
            }
        }
开发者ID:danowar2k,项目名称:seriesrenamer,代码行数:65,代码来源:LocalCollector.cs


示例17: BuildFrame

            public override bool BuildFrame(MediaFile file, MediaFrame mediaFrame, Stream buffer)
            {
               
                if (mediaFrame.IsBinaryHeader)
                {
                    buffer.Write(_videoCodecHeaderInit,0, _videoCodecHeaderInit.Length);
                }
                else
                {
                    if (mediaFrame.IsKeyFrame)
                    {
                        // video key frame
                        buffer.Write(_videoCodecHeaderKeyFrame, 0,_videoCodecHeaderKeyFrame.Length);
                    }
                    else
                    {
                        //video normal frame
                        buffer.Write(_videoCodecHeader, 0, _videoCodecHeader.Length);
                    }
                    mediaFrame.CompositionOffset = IPAddress.HostToNetworkOrder(mediaFrame.CompositionOffset & 0x00ffffff) >> 8;
                    buffer.Write(BitConverter.GetBytes(mediaFrame.CompositionOffset), 0, 3);
                }

                return base.BuildFrame(file, mediaFrame, buffer);
            }
开发者ID:langhuihui,项目名称:csharprtmp,代码行数:25,代码来源:InFileRTMPStream.cs


示例18: GetMediaForProjectByType

        public IEnumerable<IMediaFile> GetMediaForProjectByType(int projectId, FileType type)
        {
            var wikiFiles = WikiFile.CurrentFiles(projectId);

            var mediaFiles = new List<MediaFile>();

            foreach (var wikiFile in wikiFiles)
            {
                var mediaFile = new MediaFile
                {
                    Current = wikiFile.Current,
                    Archived = wikiFile.Archived,
                    CreateDate = wikiFile.CreateDate,
                    Name = wikiFile.Name,
                    Id = wikiFile.Id,
                    CreatedBy = wikiFile.CreatedBy,
                    DotNetVersion = wikiFile.DotNetVersion,
                    Downloads = wikiFile.Downloads,
                    FileType = (FileType)Enum.Parse(typeof(FileType), wikiFile.FileType),
                    FileVersion = wikiFile.NodeVersion,
                    Path = wikiFile.Path,
                    RemovedBy = wikiFile.RemovedBy,
                    SupportsMediumTrust = false,
                    UmbVersion = wikiFile.Versions,
                    Verified = wikiFile.Verified
                };

                if (mediaFiles.Contains(mediaFile) == false)
                    mediaFiles.Add(mediaFile);
            }

            return mediaFiles;
        }
开发者ID:larrynPL,项目名称:OurUmbraco,代码行数:33,代码来源:MediaProvider.cs


示例19: UpdateCreationDate

        public DateTime UpdateCreationDate(MediaFile mediaFile)
        {
            var originalCreationDate = GetOriginalCreationDate(mediaFile);

            UpdateCreationDate(mediaFile, originalCreationDate);

            return originalCreationDate;
        }
开发者ID:gabrielmoral,项目名称:PhotoSorter,代码行数:8,代码来源:WindowsProvider.cs


示例20: LoadImage

 public void LoadImage(string fileName)
 {
     var buf= new MediaFile(fileName);
     if (ByteToImageConverter.IsFileImage(buf))
     {
         this.File = buf;
     }
 }
开发者ID:BlindShot96,项目名称:tests,代码行数:8,代码来源:ImageItemWindow.xaml.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# MediaItem类代码示例发布时间:2022-05-24
下一篇:
C# Media类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap