public void RequestLiveVideoList(int number) { URLRequestMessage msg = new URLRequestMessage(this); msg.AddMessage(Global.MSG_REQUESTVIDEO_NUMBER_KEY, number.ToString()); VREvents.FireRequestLiveVideoList(msg); }
void PostLogin(URLRequestMessage msg) { if (msg.postObj == this) { m_token = msg.GetMessage(Global.MSG_LOGIN_TOKEN).ToString(); } }
IEnumerator WaitForRequestAsy(string url, RequestHandler handler, URLRequestMessage postMsg) { // Debug.Log("WaitForRequestAsy URL " + url ); if (!File.Exists(HttpHelper.GetLocalFilePath(url))) { HttpHelper httpHelper = new HttpHelper(url); httpHelper.AsyDownload(); while (!httpHelper.Done) { yield return(null); } } // Debug.Log("WaitForRequestAsy Local file path " + HttpHelper.GetLocalFilePath( url ) ); WWW www = new WWW("file://" + HttpHelper.GetLocalFilePath(url)); yield return(www); if (string.IsNullOrEmpty(www.error)) { handler(www, postMsg); } else { Debug.Log("WWW Error" + www.error); } www.Dispose(); }
public static void FirePostLogin(URLRequestMessage arg) { if (PostLogin != null) { PostLogin(arg); } }
/// <summary> /// record the start time of hovering /// </summary> public void Init(VideoInfo _info, int _index, VideoSelectWindow _p) { // save the parameter m_info = _info; parent = _p; m_index = _index; // set state to init m_state = VideoInfoUnitState.Init; // initilize the sprite URLRequestMessage msg = new URLRequestMessage(this); msg.url = m_info.coverUrl; VREvents.FireRequesTexture(msg); // update the delay time m_setting.initDelay = m_index * m_setting.InitDelayPerUnit; // hide the text ResetText(); // set the rotation and positon of the game object ResetAngleAndOffset(); // set visible to true isVisible = true; ResetSubButton(); // play the show up animation PlayInitAnimation(); }
public static void FirePostCategory(URLRequestMessage arg) { if (PostCategory != null) { PostCategory(arg); } }
public static void FireRequesTexture(URLRequestMessage arg) { if (RequesTexture != null) { RequesTexture(arg); } }
public static void FirePostTexture(URLRequestMessage arg) { if (PostTexture != null) { PostTexture(arg); } }
public static void FirePostVideoList(URLRequestMessage arg) { if (PostVideoList != null) { PostVideoList(arg); } }
public static void FireRequestCategoryVideoList(URLRequestMessage arg) { if (RequestCategoryVideoList != null) { RequestCategoryVideoList(arg); } }
public void Init(CategoryInfo info, int index, CategoryWindow p) { // initilize the sprite first URLRequestMessage msg = new URLRequestMessage(this); msg.url = info.bgUrl; VREvents.FireRequesTexture(msg); parent = p; text.text = info.name; m_info = info; img.DOFade(0, 0); text.DOFade(0, 0); text.text = ""; PlayInitAnimation(); //set the angle and position offset float angle = m_setting.anglePerUnit * ((index % parent.column) - (parent.column - 1f) / 2f); transform.localRotation = Quaternion.Euler(0, angle, 0); Vector3 pos = transform.localPosition; pos.z = (Mathf.Cos(angle * Mathf.Deg2Rad) - 1) * m_setting.radius; transform.localPosition = pos; ResetSubButton(); }
void RecieveTexture(URLRequestMessage msg) { if (msg.postObj == this) { img.sprite = (Sprite)msg.GetMessage(Global.MSG_REQUEST_TEXTURE_SPRITE_KEY); } }
/// <summary> /// save the video info /// </summary> /// <param name="msg">Message.</param> void OnShowDetail(Message msg) { if (msg.GetMessage(Global.MSG_VIDEO_INFO_KEY) != null) { m_info = (VideoInfo)msg.GetMessage(Global.MSG_VIDEO_INFO_KEY); if (m_info.Post != null) { img.sprite = m_info.Post; } else { // initilize the sprite first URLRequestMessage coverMsg = new URLRequestMessage(this); coverMsg.url = m_info.coverUrl; VREvents.FireRequesTexture(coverMsg); } description.text = m_info.description; title.text = m_info.title; } else { Debug.Log("【Error】unable to get the video info"); } }
void RecieveTexture(URLRequestMessage msg) { if (msg.postObj == this) { m_info.Post = (Sprite)msg.GetMessage(Global.MSG_REQUEST_TEXTURE_SPRITE_KEY); PlayRecieveImgAnimation(); } }
void Login() { URLRequestMessage msg = new URLRequestMessage(this); msg.AddMessage(Global.MSG_LOGIN_USERNAME, "areshero"); msg.AddMessage(Global.MSG_LOGIN_PASSWORD, "balala"); VREvents.FireRequestLogin(msg); }
void CategoryVideoHandeler(WWW www, URLRequestMessage postMsg) { JSONObject json = new JSONObject(www.text); List <VideoInfo> list = Json2VideoList(json.GetField("videoList")); string name = postMsg.GetMessage(Global.MSG_REQUEST_CATEGORYVIDEO_CATEGORY_KEY).ToString(); postMsg.AddMessage(Global.MSG_POSTVIDEO_VIDEO_KEY, list); VREvents.FirePostVideoList(postMsg); }
void RequestCategory(URLRequestMessage msg) { string url = msg.url; if (string.IsNullOrEmpty(url)) { url = Global.CategoryRequstURL; } StartCoroutine(WaitForRequest(url, CategoryHandler, msg)); }
override public void OnConfirm() { // Debug.Log("[On Confirm]" + name); base.OnConfirm(); { URLRequestMessage msg = new URLRequestMessage(this); msg.AddMessage(Global.MSG_REQUEST_CATEGORYVIDEO_CATEGORY_KEY, m_info.name); VREvents.FireRequestCategoryVideoList(msg); } }
void LoginHandler(WWW www, URLRequestMessage msg) { JSONObject info = new JSONObject(www.text); string token = info.GetField("token").str; Debug.Log("Get TOKEN" + token); msg.AddMessage(Global.MSG_LOGIN_TOKEN, token); VREvents.FirePostLogin(msg); }
void RequestCategoryVideoList(URLRequestMessage msg) { string url = msg.url; if (string.IsNullOrEmpty(url)) { string category = msg.GetMessage(Global.MSG_REQUEST_CATEGORYVIDEO_CATEGORY_KEY).ToString(); url = Global.CategoryVideoRequestURL.Replace("CATEGORY", category); msg.AddMessage(Global.MSG_POSTVIDEO_NAME_KEY, category); } StartCoroutine(WaitForRequest(url, CategoryVideoHandeler, msg)); }
void RecieveVideoList(URLRequestMessage msg) { if (m_videoManager.SetVideoList((List <VideoInfo>)msg.GetMessage(Global.MSG_POSTVIDEO_VIDEO_KEY) , msg.GetMessage(Global.MSG_POSTVIDEO_NAME_KEY).ToString())) { RefreshAndShowVideo(); } if (msg.GetMessage(Global.MSG_POSTVIDEO_NAME_KEY).ToString() != Global.LIVE_VIDEOLIST_NAME) { videoTopButton.SetName(msg.GetMessage(Global.MSG_POSTVIDEO_NAME_KEY).ToString()); } }
/// <summary> /// Deal with the request video info /// </summary> /// <param name="msg">Message.</param> void RequestVideoInfo(URLRequestMessage msg) { // Debug.Log(" Request Video Info "); string url = msg.url; if (string.IsNullOrEmpty(url)) { string number = msg.GetMessage(Global.MSG_REQUESTVIDEO_NUMBER_KEY).ToString(); url = Global.VideoRequestURL.Replace("NUMBER", number); } msg.AddMessage(Global.MSG_POSTVIDEO_NAME_KEY, "Latest"); StartCoroutine(WaitForRequest(url, DayVideoInfoHandler, msg)); }
void RequestLogin(URLRequestMessage msg) { WWWForm form = new WWWForm(); form.AddField("username", msg.GetMessage(Global.MSG_LOGIN_USERNAME).ToString()); form.AddField("password", msg.GetMessage(Global.MSG_LOGIN_PASSWORD).ToString()); string url = msg.url; if (string.IsNullOrEmpty(url)) { url = Global.LoginURL; } StartCoroutine(WaitForRequest(url, LoginHandler, msg, form)); }
/// <summary> /// extract the texture in the www, /// save in the message with key Global.MSG_REQUEST_TEXTURE_TEXTURE_KEY, /// and post the event 'PostTexture' /// </summary> /// <param name="www">Www.</param> /// <param name="postMsg">Post message.</param> void TextureHandler(WWW www, URLRequestMessage postMsg) { Texture2D tex = www.texture; Rect rec = new Rect(0, 0, tex.width, tex.height); Sprite sprite = Sprite.Create(tex, rec, new Vector2(0.5f, 0.5f), 100); if (!textureCache.ContainsKey(postMsg.url) && HttpHelper.GetDownloadState(postMsg.url) == HttpHelper.DownloadState.Finished) { textureCache.Add(postMsg.url, sprite); } postMsg.AddMessage(Global.MSG_REQUEST_TEXTURE_SPRITE_KEY, sprite); VREvents.FirePostTexture(postMsg); }
/// <summary> /// Deal with the request texture /// </summary> /// <param name="msg">Message.</param> void RequestTexture(URLRequestMessage msg) { string url = msg.url; { Sprite sprite; if (textureCache.TryGetValue(url, out sprite)) { msg.AddMessage(Global.MSG_REQUEST_TEXTURE_SPRITE_KEY, sprite); VREvents.FirePostTexture(msg); return; } } StartCoroutine(WaitForRequestAsy(url, TextureHandler, msg)); }
/// <summary> /// Transfrom the video info from jason(string) to VideoInfo(class), /// save in the message with key Global.MSG_POSTVIDEO_VIDEO_KEY /// and post the 'PostVideoList' event /// </summary> /// <param name="www">Www.</param> /// <param name="postMsg">Post message.</param> void DayVideoInfoHandler(WWW www, URLRequestMessage postMsg) { List <VideoInfo> list = new List <VideoInfo>(); JSONObject json = new JSONObject(www.text); JSONObject dailyList = json.GetField("dailyList"); if (dailyList.IsArray) { foreach (JSONObject day in dailyList.list) { JSONObject videoList = day.GetField("videoList"); list.AddRange(Json2VideoList(videoList)); } } postMsg.AddMessage(Global.MSG_POSTVIDEO_VIDEO_KEY, list); VREvents.FirePostVideoList(postMsg); }
void CategoryHandler(WWW www, URLRequestMessage msg) { List <CategoryInfo> list = new List <CategoryInfo>(); JSONObject categorys = new JSONObject(www.text); if (categorys.IsArray) { foreach (JSONObject category in categorys.list) { CategoryInfo info = new CategoryInfo(); info.name = category.GetField("name").str; info.bgUrl = category.GetField("bgPicture").str; list.Add(info); } } msg.AddMessage(Global.MSG_POSTCATEGORY_CATEGORYLIST_KEY, list); VREvents.FirePostCategory(msg); }
IEnumerator WaitForRequest(string url, RequestHandler handler, URLRequestMessage postMsg, WWWForm form = null) { // Debug.Log( "Wait for request " + url + " " + postMsg.postObj); string path = url; if (Application.platform == RuntimePlatform.IPhonePlayer) { if (File.Exists(HttpHelper.GetLocalFilePath(url))) { path = "file://" + HttpHelper.GetLocalFilePath(url); } } WWW www; if (form == null) { www = new WWW(path); } else { Debug.Log("WWW with form"); www = new WWW(path, form); } yield return(www); if (string.IsNullOrEmpty(www.error)) { handler(www, postMsg); } else { Debug.Log("WWW Error" + www.error); } www.Dispose(); }
public void RequestCategory() { URLRequestMessage msg = new URLRequestMessage(this); VREvents.FireRequestCategory(msg); }
void ResetVideoList(URLRequestMessage msg) { ClearVideos(ClearType.Disapper); }