void OnApplicationQuit() { Debug.Log("Quit the Player"); if (player != null) { player.Release(); player = null; } }
private void OnDestroy() { Debug.Log("Destroy the Player"); if (player != null) { player.Release(); player = null; } }
public static UAVPFoundation GetUAVPlayer() { UAVPFoundation player = null; if (Application.platform == RuntimePlatform.IPhonePlayer) { player = new UAVPlayerSource(); } else if (Application.platform == RuntimePlatform.OSXEditor || Application.platform == RuntimePlatform.OSXPlayer) { player = new UAVPlayerMacOSX(); } else { player = null; } return(player); }
// Start is called before the first frame update void Start() { Debug.Log("UAVP Version: " + uavp_version); // Initialize the property if (seekbar != null) { EventTrigger eventTrigger = seekbar.gameObject.AddComponent <EventTrigger>(); // When Click the Slider EventTrigger.Entry entry_PointerDown = new EventTrigger.Entry(); entry_PointerDown.eventID = EventTriggerType.PointerDown; entry_PointerDown.callback.AddListener((data) => { OnPointerDown((PointerEventData)data); }); eventTrigger.triggers.Add(entry_PointerDown); // When Touch Up the Slider EventTrigger.Entry entry_EndDrag = new EventTrigger.Entry(); entry_EndDrag.eventID = EventTriggerType.EndDrag; entry_EndDrag.callback.AddListener((data) => { OnEndDrag((PointerEventData)data); }); eventTrigger.triggers.Add(entry_EndDrag); } if (player != null) { if (autoPlay) { player.setProperty(UAVPProperty.UAVP_AUTOPLAY, 1); } else { player.setProperty(UAVPProperty.UAVP_AUTOPLAY, 0); } if (loop) { player.setProperty(UAVPProperty.UAVP_LOOP, 1); } else { player.setProperty(UAVPProperty.UAVP_LOOP, 0); } if (mute) { player.setProperty(UAVPProperty.UAVP_MUTE, 1); } else { player.setProperty(UAVPProperty.UAVP_MUTE, 0); } } if (seekbar != null) { seekbar.minValue = 0; } if (videoMat != null) { videoMat.mainTexture = null; } if (player != null) { // Register the Event UAVPlayerSource.onEvent += EventNotify; UAVPError error = player.InitPlayer(logLevel); if (error == UAVPError.UAVP_ERROR_NONE) { if (mediaPlayType == UAVPMediaType.UAVP_Streaming_Media) // Streaming { Debug.Log("Play Streaming"); URI = mediaURI; } else if (mediaPlayType == UAVPMediaType.UAVP_StreamingAsset_Media) // StreamingAsset { if (Application.platform == RuntimePlatform.OSXEditor) { Debug.Log("Play StreamingAsset Media"); if (assetFileURI != null) { URI = UAVPUtility.GetLocalURI(Application.dataPath + "/StreamingAssets/" + assetFileURI); } else { URI = null; } } else if (Application.platform == RuntimePlatform.IPhonePlayer) { URI = assetFileURI; } } else if (mediaPlayType == UAVPMediaType.UAVP_Local_Media) // Local { if (Application.platform == RuntimePlatform.OSXEditor) { Debug.Log("Play Local Media"); if (localURI != null) { URI = UAVPUtility.GetLocalURI(localURI); } else { URI = null; } } else if (Application.platform == RuntimePlatform.IPhonePlayer) { URI = localURI; } } if (URI != null) { Debug.Log("Start to play [" + URI + "]"); player.OpenMedia(URI, mediaPlayType); } else { Debug.Log("URI is null"); } openEvent.Invoke(); } else { player = null; } } else { Debug.Log("Player is null"); } }