public async Task <Playinfo> FindHasDownloadVideoPlayInfoModel(ModelPropertyBase model) { Playinfo pi = null; foreach (var m in model.playInfo) { try { var videoName = CommonHelper.Instance.AnalyzeRealVideoName(m.url); if (videoName != null) { var folder = await ApplicationData.Current.LocalFolder.CreateFolderAsync(CacheConfig.Instance.VideoFileDownloadRelativePath, CreationCollisionOption.OpenIfExists); var file = await folder.TryGetItemAsync(videoName); if (file != null) { pi = m; break; } } } catch { } } return(pi); }
public string DecideDownloadUrl(ModelPropertyBase model) { string playUrl = null; if (model != null) { if (model.playInfo.Count > 1) { var p = from m in model.playInfo where m.name == (SettingsStore.GetValueOrDefault <bool>(AppCommonConst.IS_AUTO_DOWNLOAD_HIGHT_QUALITY_VIDEO, true) ? "高清" : "标清") select m; var playInfo = p.FirstOrDefault() as Playinfo; if (playInfo != null) { playUrl = playInfo.url; } else { playUrl = model.playUrl; } } else { playUrl = model.playUrl; } } else { playUrl = null; } //WebView wv = new WebView(); //wv.NavigationCompleted += (ss, ee) => //{ // Debug.Write(ee.Uri.ToString()); //}; //wv.Source = new Uri(playUrl, UriKind.RelativeOrAbsolute); //var playArr = playUrl.Split(new string[] { "vid="}, StringSplitOptions.None); return(playUrl); }
public async Task <bool> DeleteBySingle(ModelPropertyBase item, bool isDownloadDatabase = false) { var dataModelConnection = isDownloadDatabase ? DicStore.GetValueOrDefault <SQLiteAsyncConnection>(AppCommonConst.EYESIGHT_DOWNLOAD_DATABASE, null) : DicStore.GetValueOrDefault <SQLiteAsyncConnection>(AppCommonConst.EYESIGHT_FAVORITE_DATABASE, null); if (dataModelConnection != null) { if (item != null) { item.playInfo.ForEach(async A => { await dataModelConnection.DeleteAsync(A); }); item.tags.ForEach(async A => { await dataModelConnection.DeleteAsync(A); }); await dataModelConnection.DeleteAsync(item.provider); await dataModelConnection.DeleteAsync(item.consumption); await dataModelConnection.DeleteAsync(item); return(true); } else { return(false); } } else { return(false); } }
public async Task <bool> DeleteVideos(ModelPropertyBase model) { if (model != null) { if (model.playInfo.Count > 1) { foreach (var p in model.playInfo) { try { var videoName = CommonHelper.Instance.AnalyzeRealVideoName(p.url); if (videoName != null) { var folder = await ApplicationData.Current.LocalFolder.CreateFolderAsync(CacheConfig.Instance.VideoFileDownloadRelativePath, CreationCollisionOption.OpenIfExists); var file = await folder.TryGetItemAsync(videoName); if (file != null) { await file.DeleteAsync(StorageDeleteOption.PermanentDelete); } } } catch { } } return(true); } else { try { var videoName = CommonHelper.Instance.AnalyzeRealVideoName(model.playUrl); if (videoName != null) { var folder = await ApplicationData.Current.LocalFolder.CreateFolderAsync(CacheConfig.Instance.VideoFileDownloadRelativePath, CreationCollisionOption.OpenIfExists); var file = await folder.TryGetItemAsync(videoName); if (file != null) { await file.DeleteAsync(StorageDeleteOption.PermanentDelete); } return(true); } else { return(false); } } catch { return(false); } } } else { return(false); } }
public async Task <string> DecidePlayUrl(ModelPropertyBase model) { string playUrl = null; var mp = GetCurrentPlayerFramework(); if (mp != null) { mp.StartupPosition = TimeSpan.Zero; mp.StartTime = TimeSpan.Zero; if (model != null) { //选出已经缓存的下载的PlayInfoModel var playInfoModel = await FindHasDownloadVideoPlayInfoModel(model); if (AppEnvironment.IsInternetAccess) { //如果有网络,并且此条目已经被下载,则优先加载下载后的资源,这样速度更快 if (model.isAleadyDownload && playInfoModel != null) { if (model.playInfo.Count > 1) { DicStore.AddOrUpdateValue <int>(AppCommonConst.CURRENT_VIDEO_SOLUTION_SELECTED_INDEX, model.playInfo.IndexOf(playInfoModel)); mp.IsFastForwardEnabled = true; } else { mp.IsFastForwardEnabled = false; } playUrl = playInfoModel.url; } else { if (model.playInfo.Count > 1) { var p = from m in model.playInfo where m.name == (AppEnvironment.IsWlanOrInternet && SettingsStore.GetValueOrDefault <bool>(AppCommonConst.IS_HIGHQUALITY_TOGGLLESWITCH_ON, true) ? "高清" : "标清") select m; var playInfo = p.FirstOrDefault() as Playinfo; if (playInfo != null) { DicStore.AddOrUpdateValue <int>(AppCommonConst.CURRENT_VIDEO_SOLUTION_SELECTED_INDEX, model.playInfo.IndexOf(playInfo)); mp.IsFastForwardEnabled = true; playUrl = playInfo.url; } else { mp.IsFastForwardEnabled = false; playUrl = model.playUrl; } } else { mp.IsFastForwardEnabled = false; playUrl = model.playUrl; } } } else { //没有网络则加载本地缓存的。 //这里加载本地的缓存的链接。 并且设为不可切换清晰度 mp.IsFastForwardEnabled = false; if (playInfoModel != null) { playUrl = playInfoModel.url; } } } else { mp.IsFastForwardEnabled = false; playUrl = null; } } else { mp.IsFastForwardEnabled = false; playUrl = null; } return(await PlayUrlConverte(playUrl)); }
public async Task <bool> InsertBySingle(ModelPropertyBase item, bool isDownloadDatabase = false) { var dataModelConnection = isDownloadDatabase ? DicStore.GetValueOrDefault <SQLiteAsyncConnection>(AppCommonConst.EYESIGHT_DOWNLOAD_DATABASE, null) : DicStore.GetValueOrDefault <SQLiteAsyncConnection>(AppCommonConst.EYESIGHT_FAVORITE_DATABASE, null); if (dataModelConnection != null) { if (item != null) { if (await dataModelConnection.InsertAsync(item) == 0) { await dataModelConnection.UpdateAsync(item); } var provider = item.provider; if (provider != null) { provider.parentId = item.id; if (await dataModelConnection.InsertAsync(item.provider) == 0) { await dataModelConnection.UpdateAsync(item.provider); } } var consumption = item.consumption; if (consumption != null) { consumption.parentId = item.id; if (await dataModelConnection.InsertAsync(item.consumption) == 0) { await dataModelConnection.UpdateAsync(item.consumption); } } var playInfo = item.playInfo; if (playInfo != null) { playInfo.ForEach(A => { A.parentId = item.id; }); if (await dataModelConnection.InsertAllAsync(item.playInfo) == 0) { await dataModelConnection.UpdateAllAsync(item.playInfo); } } var videoTags = item.tags; if (videoTags != null) { videoTags.ForEach(A => { A.parentId = item.id; }); if (await dataModelConnection.InsertAllAsync(item.tags) == 0) { await dataModelConnection.UpdateAllAsync(item.tags); } } return(true); } else { return(false); } } else { return(false); } }