I can play video which is there in my StreamingAssets folder. But is there a way in which I click a button and the same video gets played in the Windows Media Player. I researched a lot on this but could not find any solution.

This is the code for playing video normally,

   using UnityEngine;
using System.Collections;

public class VideoDemo : MonoBehaviour

public string filePath;
public string result;

void Start() {
    filePath = System.IO.Path.Combine (Application.streamingAssetsPath, "Demo.mp4");
    result = "";


void OnGUI() {
if(GUI.Button(new Rect(10,10,100,30),"Click Me"))

IEnumerator Example ()
    if (filePath.Contains ("://")) {
        WWW www = new WWW (filePath);
        yield return www;
        result = www.text;

    } else
        result = System.IO.File.ReadAllText (filePath);



Kindly share some ideas.


If you want to simply let windows open the default program for a file, this should do:

System.Diagnostics.Process.Start(@"file path");

If you want more control over what program opens and what arguments are passed, you can use this:

Process proc = new Process();
proc.StartInfo.FileName = @"C:\Program Files\... path to windows media player";
proc.StartInfo.Arguments = "\"" + file_name + "\"";
| improve this answer | |
  • \$\begingroup\$ Thank you. I will try this out.One more thing,considering the paths to WMP to be different for different users,how do I go about this? \$\endgroup\$ – Vivek Kalkur Mar 11 '14 at 7:15
  • \$\begingroup\$ It should be somewhere in the registry. This question comes close but is not exactly what you are looking for: stackoverflow.com/questions/19181676/… \$\endgroup\$ – pek Mar 11 '14 at 7:22
  • \$\begingroup\$ I will look into it. Anyways, thanks for your time. \$\endgroup\$ – Vivek Kalkur Mar 11 '14 at 7:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.