Ejemplo n.º 1
0
    /// <summary>
    /// Instantiates media prefabs depending on media type
    /// </summary>
    /// <param name="identifier">Identifier of artefact.</param>
    /// <param name="mediaType">Media type of media to be instantiated.</param>
    private void InstantMedia(string identifier, string mediaType)
    {
        Object mediaPrefab = new Object();

        if (mediaType == "Image")
        {
            mediaPrefab = imagePrefab;
        }
        else if (mediaType == "Audio")
        {
            mediaPrefab = audioPrefab;
        }
        else if (mediaType == "Video")
        {
            mediaPrefab = videoPrefab;
        }

        try {
//			Debug.Log("identifier: " + identifier + " mediaType: " + mediaType);
            Dictionary <string, string>[] media = DublinCoreReader.GetContextualMediaArtefactWithIdentifierAndType(identifier, mediaType);

            for (int i = 0; i < media.Length; i++)
            {
                string mediaName     = media[i]["MediaName"];
                string mediaLocation = media[i]["MediaLocation"];
//				Debug.Log(mediaName);
//				Debug.Log(mediaLocation);

                GameObject mediaInstant = Object.Instantiate(mediaPrefab, contentParent) as GameObject;
                mediaInstant.GetComponent <RectTransform>().localScale = new Vector3(1, 1, 1);

                Text mediaText = mediaInstant.transform.GetChild(1).gameObject.GetComponent <Text>();                //updates the prefab title
                mediaText.text = mediaName;

                if (mediaType == "Image")
                {
                    BrowseImpContextImg imgImpScript = mediaInstant.GetComponentInChildren <BrowseImpContextImg>();

//					Debug.Log("mediaLocation: " + mediaLocation);
                    StartCoroutine(imgImpScript.ContextImgImp(mediaLocation));                     //TODO this coroutine is not working properly
                }
//				else if (mediaType == "Audio")
//				{
//					mediaPrefab = audioPrefab;
//				}
//				else if (mediaType == "Video")
//				{
//					mediaPrefab = videoPrefab;
//				}
            }
        }
        catch (System.Exception ex)
        {
            Debug.Log("No Contextual Media for this artefact");
            GameObject mediaInstant = Object.Instantiate(noMediaPrefab, contentParent) as GameObject;
            mediaInstant.GetComponent <RectTransform>().localScale = new Vector3(1, 1, 1);
        }
    }
Ejemplo n.º 2
0
    public void TestGetContextualMediaOfForArtefactWithIdentifierAndType()
    {
        Dictionary <string, string>[] contextualMedia = DublinCoreReader.GetContextualMediaArtefactWithIdentifierAndType("TestMonk", "Image");

        Assert.That(contextualMedia [0] ["MediaName"] == "MetaPipe_TestTexs_1000");
        Assert.That(contextualMedia [0] ["MediaType"] == "Image");
        Assert.That(contextualMedia [0] ["MediaLocation"] == "/VerticeArchive/TEST/TestTexs_1000.jpg");

        Assert.That(contextualMedia [1] ["MediaName"] == "MetaPipe_TestTexs_2000W");
        Assert.That(contextualMedia [1] ["MediaType"] == "Image");
        Assert.That(contextualMedia [1] ["MediaLocation"] == "/VerticeArchive/TEST/TestTexs_2000W.jpg");
    }
Ejemplo n.º 3
0
 public void TestGetContextualMediaOfForArtefactWithIdentifierAndType_InvalidType()
 {
     Dictionary <string, string>[] contextualMedia = DublinCoreReader.GetContextualMediaArtefactWithIdentifierAndType("TestMonk", "INVALID TYPE");
 }
Ejemplo n.º 4
0
 public void TestGetContextualMediaOfForArtefactWithIdentifierAndType_InvalidIdentifier()
 {
     Dictionary <string, string>[] contextualMedia = DublinCoreReader.GetContextualMediaArtefactWithIdentifierAndType("DOES NOT EXIST", "Image");
 }