【问题标题】:Passing video path from a media element to a media element within another class将视频路径从媒体元素传递到另一个类中的媒体元素
【发布时间】:2013-06-07 10:34:07
【问题描述】:

您好,我正在开发一款类似于 Power Point 的软件。要添加视频,我添加视频幻灯片,然后选择浏览以搜索视频。添加视频后,您可以选择右键单击该视频,然后在选项中编辑视频。选择编辑视频将打开另一个页面,其中包含一个媒体元素和一个带有播放、暂停、停止按钮的滑动条。当我从主窗口类调用视频编辑器类时,视频路径肯定会正确传递(我已经逐步完成并发现了这一点)它将视频路径添加到媒体元素源,但它永远不会加载,好像路径从未过去了。在编辑器中,有一个浏览按钮可以添加更多视频,当我以这种方式添加视频时,它们会与媒体元素一起正确显示。

VideoWindow 是视频编辑器的类。

public VideoWindow(Video __video, Roots __roots)
    {

        InitializeComponent();

        _roots = __roots;
        string videoFilePathFull = "";
        foreach (string file in Directory.EnumerateFiles(_roots.RunTimeTemp, "*.mp4*", SearchOption.AllDirectories))
        {
            videoFilePathFull = file;
        }
        mediaElement1.Source = new Uri(videoFilePathFull, UriKind.Relative);
        _staticVideo = __video;
        _tempVideo.Path = videoFilePathFull;
        initVideo();

    }

editVideoElement 方法是在主窗口中调用的方法

private void editVideoElement(object sender, RoutedEventArgs e) {

            string __vidFileName = "";
            DesignerItem __item = getSingleSelectedElement();
            ComponentProperties __props = _slideFactory.GetComponentProperties(__item.Name);
            __vidFileName = __props.Video.Path;


            VideoWindow __slideVideo = new VideoWindow(__props.Video, roots);
            __slideVideo.Owner = this;
            __slideVideo.ShowDialog();

    }

【问题讨论】:

    标签: c# dialog filepath mediaelement


    【解决方案1】:

    我通过 __props.Video 传递视频,在 VideoWindow 类的页面加载中,我将媒体元素设置为具有路径。从那以后,我在类中创建了一个方法,如果曾经传递过路径,我会在 VideoWindow 类的页面加载中调用该方法,现在该路径正在传递到媒体元素中:)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-01-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多