블로그 이미지
Every unexpected event is a path to learning for you.

카테고리

분류 전체보기 (2737)
Unity3D (817)
Programming (474)
Server (33)
Unreal (4)
Gamebryo (56)
Tip & Tech (228)
협업 (58)
3DS Max (3)
Game (12)
Utility (136)
Etc (96)
Link (32)
Portfolio (19)
Subject (90)
iOS,OSX (53)
Android (14)
Linux (5)
잉여 프로젝트 (2)
게임이야기 (3)
Memories (20)
Interest (38)
Thinking (38)
한글 (30)
PaperCraft (5)
Animation (408)
Wallpaper (2)
재테크 (18)
Exercise (3)
나만의 맛집 (3)
냥이 (10)
육아 (16)
Total
Today
Yesterday
04-25 00:00

[사용엔진] Unity 2021.3.14f1

 

유니티 내장 VideoPlayer를 사용해서 Local 파일 로드를 할 때, 예전부터 Path 앞에 file:// 를 붙여서 사용했었는데 

이번에 URL을 그대로 사용하고 VideoPlayer로 동영상을 플레이 했는데

이전 폰들은 잘 나오는데 Android 12에서 제목과 같은 에러가 나면서 동영상 플레이가 안된다.

 

확인해보니 URL에서 file:// 을 빼라고 한다.

(Android 12 미만에서도 빼고 플레이 해보니 잘 된다.)

 

P.s. VideoPlayer는 file:// 빼야 되고, Assetbundle은 여전히 file:// 있어야 되는 것 같다.

 

[참조] 

We support webm across all platforms, but I am unsure about vp8 files. Something you should try is removing the files:// from the path and making sure the file is where you think it is. I saw someone else having the same issue https://stackoverflow.com/questions...error-ndkmediaextractor-cant-create-http-serv

 

[출처]

https://forum.unity.com/threads/videoplayer-url-issue-with-vp8-webm-on-android-androidvideomedia-error-opening-extractor-10002.1255434/

 

Bug - VideoPlayer.url issue with vp8/webm on Android: AndroidVideoMedia: Error opening extractor: -10002

I try to play a vp8 video on an Android device (Galaxy S10e, Android 12) using VideoPlayer.url with a file URI. For example: videoPlayer.url =...

forum.unity.com

 

반응형
Posted by blueasa
, |

[추가]

Unity의 VideoPlayer iOS는 H264/H265를 지원안한다고 한다.

VP8(.webm) 쓰자..

 

 

So the problem was, H264 and H265 Codecs are not supported for some reasons in IOS, You have to convert all your videos to VP8 Codec in unity, and it will render fine in ios devices. 

And Voila, it should work fine now.

 

 

[출처] https://stackoverflow.com/questions/65978459/unityengine-videoplayer-not-rendering-video-on-ios-devices

 

UnityEngine.Videoplayer not rendering video on IOS Devices

I am using unity's video player to render a video in the scene, I spawn the video in the scene dynamically, (Render Mode: Camera Far Plane) Let it play on awake And Assign its texture on to a raw

stackoverflow.com

 

반응형
Posted by blueasa
, |
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Video;
 
public class Scene_Intro : MonoBehaviour 
{
	public VideoPlayer vid;
  
	void Start()
    {
    	vid.loopPointReached += CheckOver;
    }
 
    void CheckOver(UnityEngine.Video.VideoPlayer vp)
    {
         print  ("Video Is Over");
    }
}

 

 

[출처] https://mentum.tistory.com/170

 

VideoPlayer 끝난건지 확인하기.

출처 : https://forum.unity.com/threads/how-to-know-video-player-is-finished-playing-video.483935/ 1234567891011121314151617using System.Collections;using System.Collections.Generic;using UnityEngine;using UnityEngine.Video; public class Scene_Intro : Mon

mentum.tistory.com

[참조] https://forum.unity.com/threads/how-to-know-video-player-is-finished-playing-video.483935/

 

Video - How to Know video player is finished playing video?

I want to have callback when video player is finished playing video. If i use videoplayer.isPlaying , this won't work because this will send call back...

forum.unity.com

 

반응형
Posted by blueasa
, |

Ever stuck on how to render a video on a TV screen in a game? Lets us learn the concept of playing a video in Unity.

You can import many different formats of video file into Unity. Unity stores such imported video files as VideoClip assets. A Video Clip is an imported video file, which the Video Player component uses to play video content. The playing video also accompanies audio content, if it has any. Typical file extensions for video files include .mp4, .mov, .webm, and .wmv.

To check the video file compatibility in unity, click here.

The Video Player component

Video Player component is used to attach video files to GameObjects, and play them on the GameObject’s Texture at run time.

By default, the Material Property of a Video Player component is set to MainTex, which means that when the Video Player component is attached to a GameObject that has a Renderer, it automatically assigns itself to the Texture on that Renderer (because this is the main Texture for the GameObject).

You can also set the following specific target for the video to play on, using the Render Mode property of Video Player:

  • A Camera plane
  • A Render Texture
  • A Material Texture parameter
  • Any Texture field in a component

Playing a video already in Assets

If you already have a video clip in your asset folder, you can simply set the Source property of Video Player component to Video Clip and drag and drop your video clip in the inspector. Alternatively, you can set the video clip in script using clip property.

    public VideoPlayer myVideoPlayer;
    public VideoClip myClip;
    myVideoPlayer.clip = myClip;

You can tick the property Play On Awake if you want to play the video the moment the Scene launches. Otherwise you can trigger the video playback with Play() command at another point during run time.

    myVideoPlayer.Play();

Playing Video from url in Unity

You might be having a video on server which you want to load on runtime. Here is how we can do it:

    private IEnumerator playVideoInThisURL(string _url)
    {
        myVideoPlayer.source = UnityEngine.Video.VideoSource.Url;
        myVideoPlayer.url = _url;
        myVideoPlayer.Prepare();

        while (myVideoPlayer.isPrepared == false){
           yield return null; 
        }
        myVideoPlayer.Play();
    }

Here, we have waited till the video player successfully prepared the content to be played.

Note, the url can also contain the path of the file.

Downloading and Saving Video from Url

The above line of code plays the video directly from the url. Alternatively, you can download the video file and then play the video from this path. The line of code below downloads the video clip and saves it at Application.persistentDataPath.

    private IEnumerator loadVideoFromThisURL(string _url)
    {
        UnityWebRequest _videoRequest = UnityWebRequest.Get(_url);
        yield return _videoRequest.SendWebRequest();

        if (_videoRequest.isDone == false || _videoRequest.error != null)
        {
            yield return null;
        }
        else
        {
            Debug.Log("Video Done - " + _videoRequest.isDone);
            byte[] _videoBytes = _videoRequest.downloadHandler.data;
            string _pathToFile = Path.Combine(Application.persistentDataPath, "video.mp4");
            File.WriteAllBytes(_pathToFile, _videoBytes);
            StartCoroutine(this.playVideoInThisURL(_pathToFile));
            yield return null;
        }
    }

Now we have learnt the art of playing video in Unity. Drop in your comments for any queries or feedback.

Happy Coding!

 

[출처] https://codesaying.com/playing-video-in-unity/

 

Playing Video in Unity - Code Saying

Ever stuck on how to render a video on a TV screen in a game? Or a full screen video? Lets us learn the art playing a video in Unity.

codesaying.com

 

반응형
Posted by blueasa
, |

[링크] https://yoonstone-games.tistory.com/87

 

[Unity] Canvas/UI 에 영상 넣는 방법 (Raw Image, Render Texture)

지난 게시글에서 plane, cube, sphere 에 영상 넣는 방법을 알아봤다면 이번에는 UI인 Canvas Image에 영상 넣는 방법을 함께 알아보도록 하겠습니다 :) ↓ 지난 게시글 ↓ https://yoonstone-games.tistory.com/39?cate

yoonstone-games.tistory.com

 

반응형
Posted by blueasa
, |