1

I'm trying to make application that would open video select random file on Raspberry PI running Windows 10 IoT Core. But I am getting the following error:

enter image description here

Code:

private async void button1_Click(object sender, RoutedEventArgs e)
    {
        await VideoAc();
    }

    private async Task VideoAc()
    {
        Debug.WriteLine("Video opening");
        RandomVideo();
        video.AutoPlay = true;
        video.Visibility = Visibility.Visible;
        video.Play();

    }


    private void video_MediaEnded(object sender, RoutedEventArgs e)
    {
        video.AutoPlay = false;
        video.Visibility = Visibility.Collapsed;

    }
    private void RandomVideo()
    {
        var random = new Random();

        var fileNames = Directory.GetFiles("ms-appx:///wmv", "*.wmv", SearchOption.AllDirectories);

        var path = fileNames[random.Next(0, fileNames.Length)];

        Debug.WriteLine(path);

        video.Source = new Uri(path);
    }
Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
Hakan Kaya
  • 65
  • 7
  • Similar problem with suggestion to fix here (noit answered yet though) http://stackoverflow.com/questions/38425955/windows-10-iot-core-video-open-close – dbmitch Jul 24 '16 at 19:29

1 Answers1

1

You might want to as well try the alternative UWP API,

StorageFolder.GetFilesAsync()

Find more details in here. You can also apply your custom query/filter using this API,

StorageFolder.GetFilesAsync(CommonFileQuery)

More details from here.

Directory.GetFiles()

On the other hand, is only available in legacy .NET framework. I don't think you should use it in your UWP apps.

Hakan Kaya
  • 65
  • 7
Jackie
  • 2,032
  • 1
  • 12
  • 14