-1

I want to play video directly from the server in MediaElement. (The source will be the server) I have a URL of the server: http://videotherapy.co/dev/vt/api/dispatcher.php

And post the following json:

{"videoId":"22-1","api":"get-training-video"}

(where 22-1 is the videoId)

XAML code:

<Window x:Class="MediaElementApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="467.91" Width="1300">
<Grid>
<MediaElement x:Name="mediaElement" HorizontalAlignment="Left" Height="418" Margin="246,10,0,0" VerticalAlignment="Top" Width="1036" LoadedBehavior="Manual" UnloadedBehavior="Stop" Source="Images\Wildlife.wmv" />
<Button x:Name="play" HorizontalAlignment="Left" Margin="538,161,0,0" VerticalAlignment="Top" Width="100" Height="84" Click="play_Click" >
    <Button.Background>
        <ImageBrush ImageSource="Images/smiley.jpg"/>
    </Button.Background>
</Button>

</Grid>

c# code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace MediaElementApp
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
    }

        private void play_Click(object sender, RoutedEventArgs e)
        {

            mediaElement.Play();
        }
    }
}

How to do this? I would like for help.

  • A minimal requirement would be for you to at least have tried something and come here when you encounter a problem. – BCdotWEB Apr 01 '15 at 10:49

1 Answers1

0

The MediaElement accepts a URI as Source. Like this, it can stream the video from the web to the client application.

If this is somehow not possible in your case. You'll have to download the video to a File. Then pass the location of this file to the Source property of the MediaElement

bkardol
  • 1,258
  • 1
  • 20
  • 32