我是靠谱客的博主 文艺康乃馨,最近开发中收集的这篇文章主要介绍基于AVpro视频播放器的展馆视频播放,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using RenderHeads.Media.AVProVideo;

脚本不需要赋值,挂在物体上即可
public class VideoShowOne : MonoBehaviour
{
    public static VideoShowOne showOne;bool IsPlay = false;
    private void Awake()
    {
        showOne = this;
    }
    public MediaPlayer mediaPlayer;
  public void ShowOne(MediaPlayer media, string path) {
        if (mediaPlayer!=null)
        {

            mediaPlayer.Control.CloseVideo();
        }
       
      
        mediaPlayer = media;
        media.OpenVideoFromFile(MediaPlayer.FileLocation.RelativeToStreamingAssetsFolder, path, true);
        media.Play();
    }
    public void Tog(MediaPlayer media, string path) {
        if (media.Control.IsPlaying())
        {
            media.Pause();
            media.Control.CloseVideo();
        }
        else
        {
            ShowOne(media, path);

        }




    }
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}

//存储信息脚本

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using RenderHeads.Media.AVProVideo;

public class Cun : MonoBehaviour
{
    public MediaPlayer MediaPlayer;public string path;
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}

//重写控制器基类

using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using UnityEditor;
using UnityEngine;
using VRTK;
using RenderHeads.Media.AVProVideo;

/// <summary>
/// 重写的脚本基类
/// </summary>
public class VideoPress : MonoBehaviour
{
    public VRTK_Pointer RighPO;
    private void Awake()
    {
        RighPO = GetComponent<VRTK_Pointer>();
        RighPO.DestinationMarkerEnter += Pointer_DestinationMarkerEnter;
        RighPO.DestinationMarkerExit += Pointer_DestinationMarkerExit;
        RighPO.DestinationMarkerSet += M_Pointer_DestinationMarkerSet;

    }

    private void M_Pointer_DestinationMarkerSet(object sender, DestinationMarkerEventArgs e)
    {
        print("选择物体" + e.target.name);

        Cun video = e.target.GetComponent<Cun>();//获取物体身上的           
        if (video)
        {
            VideoShowOne.showOne.Tog(video.MediaPlayer, video.path);
        }
    }

    public void OnDestroy()
    {
        RighPO.DestinationMarkerEnter -= Pointer_DestinationMarkerEnter;
        RighPO.DestinationMarkerExit -= Pointer_DestinationMarkerExit;
    }

    private void Pointer_DestinationMarkerExit(object sender, DestinationMarkerEventArgs e)
    {
        print("射线退出物体");

    }
    private void Pointer_DestinationMarkerEnter(object sender, DestinationMarkerEventArgs e)
    {
        print("射线进入物体");

    }
}

最后

以上就是文艺康乃馨为你收集整理的基于AVpro视频播放器的展馆视频播放的全部内容,希望文章能够帮你解决基于AVpro视频播放器的展馆视频播放所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(68)

评论列表共有 0 条评论

立即
投稿
返回
顶部