Class Media
Class of media files.
媒體檔案類別。
Inherited Members
Namespace: Votanic.vMedia
Assembly: Votanic.vMedia.dll
Syntax
[Serializable]
public class Media : Element
Constructors
Media(String, Int32, Single, Boolean, ExternalAudio)
Declare a media.
宣告一個媒體。
Declaration
public Media(string path, int audioChannel = 0, float imageDuration = 3F, bool videoPreview = false, ExternalAudio externalAudio = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | Path of media wanted to read |
System.Int32 | audioChannel | Channel of audio type media |
System.Single | imageDuration | Play duration of image type media |
System.Boolean | videoPreview | Load preview image of video type media if true |
ExternalAudio | externalAudio | External audio setting |
Fields
audioChannel
Channel of audio type media.
音訊類型的媒體頻道。
Declaration
[Tooltip("Channel of audio type media.\n音訊類型的媒體頻道。")]
public int audioChannel
Field Value
Type | Description |
---|---|
System.Int32 |
externalAudio
External audio setting.
外置音訊設定。
Declaration
[Tooltip("External audio setting.\n外置音訊設定")]
public ExternalAudio externalAudio
Field Value
Type | Description |
---|---|
ExternalAudio |
imageDuration
Play duration of image type media.
影像類型的媒體播放長度。
Declaration
[Tooltip("Play duration of image type media.\n影像類型的媒體播放長度。")]
public float imageDuration
Field Value
Type | Description |
---|---|
System.Single |
path
Path of media wanted to read.
想讀取的媒體路徑。
Declaration
[Tooltip("Please fill in the File Name or Directory Name into the Path field.\n請在 Path 欄填上檔案或路徑名稱。")]
public string path
Field Value
Type | Description |
---|---|
System.String |
type
Type of media wanted to read.
想讀取的媒體類型。
Declaration
[Tooltip("Type of media wanted to read.\n想讀取的媒體類型。")]
public MediaType type
Field Value
Type | Description |
---|---|
MediaType |
videoPreview
Load preview image of video type media if true.
當 true 時載入視訊類型的預覽影像。
Declaration
[Tooltip("Load preview image of video type media.\n載入視訊類型的預覽影像。")]
public bool videoPreview
Field Value
Type | Description |
---|---|
System.Boolean |
Properties
duration
Play duration of media.
媒體播放長度。
Declaration
public float duration { get; }
Property Value
Type | Description |
---|---|
System.Single |
mediaIndex
Index on media player.
在媒體播放器的編號。
Declaration
public int mediaIndex { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Methods
LoadAudio(String, AudioType, AudioSource)
Load an image from url or file.
在網址或檔案載入影像。
StartCoroutine(LoadAudio("../Resources/Audio/abc.mp3", AudioType.MPEG, audioSource))
Declaration
public static IEnumerator LoadAudio(string path, AudioType type, AudioSource audioSource)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | Path |
UnityEngine.AudioType | type | Audo type |
UnityEngine.AudioSource | audioSource | Audio soruce component |
Returns
Type | Description |
---|---|
System.Collections.IEnumerator |
LoadImage(String)
Load an image from file.
在檔案載入影像。
Texture2D t = LoadImage("../Resources/Image/abc.png")
Declaration
public static Texture2D LoadImage(string path)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | Path of file |
Returns
Type | Description |
---|---|
UnityEngine.Texture2D |
SaveEXR(String, Texture2D)
Save an image from Unity to storage as EXR format.
將影像儲存為 exr 格式。
SaveTGA("../Resources/Image/abc.exr", texture)
Declaration
public static void SaveEXR(string path, Texture2D texture)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | Path of file |
UnityEngine.Texture2D | texture | The image |
SaveJPG(String, Texture2D)
Save an image from Unity to storage as JPG format.
將影像儲存為 jpg 格式。
SaveJPG("../Resources/Image/abc.jpg", texture)
Declaration
public static void SaveJPG(string path, Texture2D texture)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | Path of file |
UnityEngine.Texture2D | texture | The image |
SavePNG(String, Texture2D)
Save an image from Unity to storage as PNG format.
將影像儲存為 png 格式。
SavePNG("../Resources/Image/abc.png", texture)
Declaration
public static void SavePNG(string path, Texture2D texture)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | Path of file |
UnityEngine.Texture2D | texture | The image |
SaveTGA(String, Texture2D)
Save an image from Unity to storage as TGA format.
將影像儲存為 tga 格式。
SaveTGA("../Resources/Image/abc.tga", texture)
Declaration
public static void SaveTGA(string path, Texture2D texture)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | Path of file |
UnityEngine.Texture2D | texture | The image |
Type(String)
Retrun media type from extension.
由副檔名傳回媒體類型。
Type(".mp3")
Declaration
public static MediaType Type(string extension)
Parameters
Type | Name | Description |
---|---|---|
System.String | extension | Extension |
Returns
Type | Description |
---|---|
MediaType |