0

This is a question On Unity 3d. 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"))
    {
        StartCoroutine(Example());
    }
}

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.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Vivek Kalkur
  • 2,200
  • 2
  • 21
  • 40

1 Answers1

0

This post covers using Process.start to open up files in their default handlers or using a specific app, like notepad.exe. You should be able to target Windows media player using commands highlighted here

ath.