【问题标题】:Play video from StreamingAssets folder in Windows Media Player?(Unity 3D)在 Windows Media Player 中播放 StreamingAssets 文件夹中的视频?(Unity 3D)
【发布时间】:2014-03-11 06:49:55
【问题描述】:

这是一个关于 Unity 3d 的问题。我可以播放 StreamingAssets 文件夹中的视频。但是有没有一种方法可以让我单击一个按钮,然后在 Windows Media Player 中播放相同的视频。我对此进行了很多研究,但找不到任何解决方案。

这是正常播放视频的代码,

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);

    }
 }

    }

欢迎分享一些想法。

【问题讨论】:

    标签: unity3d windows-media-player


    【解决方案1】:

    This post 涵盖使用 Process.start 在其默认处理程序中打开文件或使用特定应用程序(如 notepad.exe)。您应该能够使用突出显示的命令来定位 Windows 媒体播放器 here

    ath.

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-07-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多