void FinishLoadingUrls() { List <VideoInfo> videoInfos = resolver.videoInfos; foreach (VideoInfo info in videoInfos) { if (info.VideoType == VideoType.Mp4 && info.Resolution == (360)) { if (info.RequiresDecryption) { //The string is the video url videoAreReadyToPlay = false; Debug.Log("Decript"); StartCoroutine(resolver.DecryptDownloadUrl(DecryptionFinished, info)); break; } else { videoUrl = info.DownloadUrl; videoAreReadyToPlay = true; } break; } } }
void FinishLoadingUrls() { Debug.Log("ok"); List <VideoInfo> videoInfos = resolver.videoInfos; foreach (VideoInfo info in videoInfos) { if (info.VideoType == VideoType.Mp4 && info.Resolution == (720)) { if (info.RequiresDecryption) { //The string is the video url Debug.Log("Decript"); StartCoroutine(resolver.DecryptDownloadUrl(DecryptionFinished, info)); break; } else { videoUrl = info.DownloadUrl; this.gameObject.GetComponent <MediaPlayerCtrl>().m_strFileName = videoUrl; this.gameObject.GetComponent <MediaPlayerCtrl>().Play(); } break; } } }
void FinishLoadingAudioUrls() { List <VideoInfo> audioInfos = resolver.videoInfos; foreach (VideoInfo info in audioInfos) { if (info.VideoType == VideoType.Mp4 && info.Resolution == (360)) { if (info.RequiresDecryption) { //The string is the video url with audio StartCoroutine(resolver.DecryptDownloadUrl(DecryptAudioDone, info)); } else { audioVideoUrl = info.DownloadUrl; } break; } } }
public void ArrangeTargetVideoInfo() { var l_VideoInfos = _reqResolver.videoInfos; foreach (var videoInfo in l_VideoInfos) { //Read MP4/360 url if (videoInfo.VideoType == VideoType.Mp4 && videoInfo.Resolution == 360) { if (videoInfo.RequiresDecryption) { StartCoroutine(_reqResolver.DecryptDownloadUrl(DecodeEnd => GetInstance.VideoURL = DecodeEnd, videoInfo)); } else { VideoURL = videoInfo.DownloadUrl; } break; } } }
void FinishLoadingUrls() { List <VideoInfo> videoInfos = resolver.videoInfos; foreach (VideoInfo info in videoInfos) { if (info.VideoType == VideoType.Mp4 && info.Resolution == (720)) { if (info.RequiresDecryption) { //The string is the video url StartCoroutine(resolver.DecryptDownloadUrl(DecryptionFinished, info)); break; } else { StartCoroutine(Play(info.DownloadUrl)); } break; } } }
//this will run only in another thread. void FinishLoadingUrls() { List <VideoInfo> videoInfos = resolver.videoInfos; videoDecryptDone = false; audioDecryptDone = false; //Get the video with audio first foreach (VideoInfo info in videoInfos) { if (info.VideoType == VideoType.Mp4 && info.Resolution == (360)) { if (info.RequiresDecryption) { //The string is the video url with audio StartCoroutine(resolver.DecryptDownloadUrl(DecryptAudioDone, info)); } else { audioVideoUrl = info.DownloadUrl; } break; } } int quality = 360; switch (videoQuality) { case VideoQuality.mediumQuality: quality = 360; break; case VideoQuality.Hd720: quality = 720; break; case VideoQuality.Hd1080: quality = 1080; break; case VideoQuality.Hd1440: quality = 1440; break; case VideoQuality.Hd2160: quality = 2160; break; } bool foundVideo = false; //Get the high quality video foreach (VideoInfo info in videoInfos) { if (info.VideoType == VideoType.Mp4 && info.Resolution == (quality)) { if (info.RequiresDecryption) { //The string is the video url StartCoroutine(resolver.DecryptDownloadUrl(DecryptVideoDone, info)); } else { videoUrl = info.DownloadUrl; videoAreReadyToPlay = true; } foundVideo = true; //videoAreReadyToPlay = true; break; } } if (!foundVideo && quality == 2160) { foreach (VideoInfo info in videoInfos) { if (info.FormatCode == 313) { Debug.Log("Found but with unknow format in results, check to see if the video works normal."); if (info.RequiresDecryption) { //The string is the video url StartCoroutine(resolver.DecryptDownloadUrl(DecryptVideoDone, info)); } else { videoUrl = info.DownloadUrl; videoAreReadyToPlay = true; } foundVideo = true; //videoAreReadyToPlay = true; break; } } } //if desired quality not found try another lower quality. if (!foundVideo) { Debug.Log("Desired quality not found, playing with low quality, check if the video id: " + videoId + " support that quality!"); foreach (VideoInfo info in videoInfos) { if (info.VideoType == VideoType.Mp4 && info.Resolution == (360)) { if (info.RequiresDecryption) { //The string is the video url StartCoroutine(resolver.DecryptDownloadUrl(DecryptVideoDone, info)); } else { videoUrl = info.DownloadUrl; videoAreReadyToPlay = true; } break; } } } }
} //END GetTheVideo //----------------------------------// private void GetDownloadUrlsComplete() //----------------------------------// { if( ShowDebug ) { Debug.Log( "YouTubeFinder.cs GetDownloadUrlsComplete() start" ); } List<VideoInfo> videoInfos = requestResolver.videoInfos; foundVideo = false; VideoInfo info = null; VideoInfo highestQualityVideoInfo = null; VideoInfo matchingVideoInfo = null; //Get the quality video we requested foreach( VideoInfo _info in videoInfos ) { if( _info != null && _info.VideoType == VideoType.Mp4 && _info.Resolution != 0 ) { if( highestQualityVideoInfo == null ) { highestQualityVideoInfo = _info; } else if( highestQualityVideoInfo.Resolution < _info.Resolution ) { highestQualityVideoInfo = _info; } //If we're not looking for the "highest quality", then we need to try to find a match for the quality we're looking for if( !useHighestQuality && _info.Resolution == ( videoQuality ) ) { //We found a match! Let's break out of the search matchingVideoInfo = _info; if( ShowDebug ) { Debug.Log( "YoutubeFinder.cs GetVideoInAnotherThread() found matching video in foreach..." ); } break; } else { if( ShowDebug ) { Debug.Log( "YoutubeFinder.cs GetVideoInAnotherThread() Video is not a match... useHighestQuality = " + useHighestQuality + ", SearchResolution = " + videoQuality + ", Video.Resolution = " + _info.Resolution ); } } } } //Set the VideoInfo to what either our search results or the highest quality if( matchingVideoInfo != null ) { info = matchingVideoInfo; if( ShowDebug ) { Debug.Log( "YoutubeFinder.cs GetVideoInAnotherThread() found the video we searched for! Resolution = " + info.Resolution + ", audio.Bitrate = " + info.AudioBitrate ); } } //If we found any valid videos to play... else if( highestQualityVideoInfo != null ) { info = highestQualityVideoInfo; if( ShowDebug ) { Debug.Log( "YoutubeFinder.cs GetVideoInAnotherThread() using the highest quality we could find! Resolution = " + info.Resolution + ", audio.Bitrate = " + info.AudioBitrate ); } } //We found a video to play! if( info != null ) { //Check if we need to decrypt the URL if( info.RequiresDecryption ) { StartCoroutine( requestResolver.DecryptDownloadUrl( VideoUrlDecryptComplete, info ) ); } else { VideoUrlDecryptComplete( info.DownloadUrl ); } //Check if the video also contains audio, if it does we don't need to use a 2nd Unity video player to play audio from a different stream if( info.AudioBitrate != 0 ) { if( ShowDebug ) { Debug.Log( "YoutubeFinder.cs GetVideoInAnotherThread() video contains an audio stream, no need to use a 2nd video player just for audio" ); } audioURL = ""; isAudioReady = true; } else { if( ShowDebug ) { Debug.Log( "YoutubeFinder.cs GetVideoInAnotherThread() video does not contain an audio stream, so we need to use a 2nd video player just for audio" ); } GetAudioURL( videoInfos ); } } else //If we couldn't find any video to play... { if( ShowDebug ) { Debug.Log( "YoutubeFinder.cs GetVideoInAnotherThread() Unable to find any videos to play in MP4 format for the sent in URL = " + videoURL ); } foundVideo = false; } } //END GetDownloadUrlsComplete