public static async Task OnMediaAddedAsync(this IEnumerable <IMediaEventHandler> handlers, IMediaStore store, MediaEntry entry, CancellationToken cancellationToken = default) { var pending = TaskPool.Get(); try { foreach (var handler in handlers) { var task = handler.OnMediaAddedAsync(store, entry, cancellationToken); if (!task.IsReal()) { continue; } if (task.IsCompleted || task.IsCanceled || task.IsFaulted) { continue; } pending.Add(task); } if (pending.Count > 0) { await Task.WhenAll(pending); } } finally { TaskPool.Return(pending); } }
/*void returns need to change of course * public virtual void GetMesh() * { * }*/ public PrimitiveBaseShape Copy() { PrimitiveBaseShape copy = (PrimitiveBaseShape)MemberwiseClone(); if (Media != null) { PrimitiveBaseShape.MediaList dupeMedia = new PrimitiveBaseShape.MediaList(); lock (Media) { foreach (MediaEntry me in Media) { if (me != null) { dupeMedia.Add(MediaEntry.FromOSD(me.GetOSD())); } else { dupeMedia.Add(null); } } } copy.Media = dupeMedia; } return(copy); }
public override Task OnMediaAddedAsync(IMediaStore store, MediaEntry entry, CancellationToken cancellationToken = default) { var pending = AsyncExtensions.TaskPool.Get(); try { var notify = _notify.Clients.All.SendAsync(Constants.Notifications.ReceiveMessage, "info", $"Added new {entry.Type} '{entry.Name}'", cancellationToken); if (notify.IsCompleted || notify.IsCanceled || notify.IsFaulted) { return(AsyncExtensions.NoTask); } if (notify.Status != TaskStatus.Running) { notify.Start(); } pending.Add(notify); return(Task.WhenAll(pending)); } finally { AsyncExtensions.TaskPool.Return(pending); } }
/// <summary> /// Set the media entry on the face of the given part. /// </summary> /// <param name="part">/param> /// <param name="face"></param> /// <param name="me">If null, then the media entry is cleared.</param> public void SetMediaEntry(SceneObjectPart part, int face, MediaEntry me) { // m_log.DebugFormat("[MOAP]: SetMediaEntry for {0}, face {1}", part.Name, face); int numFaces = part.GetNumberOfSides(); if (part.Shape.Media == null) { part.Shape.Media = new PrimitiveBaseShape.PrimMedia(numFaces); } else { part.Shape.Media.Resize(numFaces); } if (!CheckFaceParam(part, face)) { return; } // ClearMediaEntry passes null for me so it must not be ignored! lock (part.Shape.Media) part.Shape.Media[face] = me; UpdateMediaUrl(part, UUID.Zero); SetPartMediaFlags(part, face, me != null); part.ScheduleFullUpdate(PrimUpdateFlags.FindBest); part.TriggerScriptChangedEvent(Changed.MEDIA); }
public MediaEntry GetMediaEntry(SceneObjectPart part, int face) { MediaEntry me = null; if (!CheckFaceParam(part, face)) { return(null); } if (part.Shape.Media == null) { return(null); // no media entries } if (face >= part.Shape.Media.Count) { return(null); // out of range } me = part.Shape.Media[face]; if (me == null) // no media entry for that face { return(null); } // TODO: Really need a proper copy constructor down in libopenmetaverse me = MediaEntry.FromOSD(me.GetOSD()); // m_log.DebugFormat("[MOAP]: GetMediaEntry for {0} face {1} found {2}", part.Name, face, me); return(me); }
public IActionResult Create(int userId) { MediaEntry newMediaEntry = new MediaEntry(); newMediaEntry.UserId = userId; return(View(newMediaEntry)); }
public void SetMediaEntry(ISceneChildEntity part, int face, MediaEntry me) { CheckFaceParam(part, face); if (null == part.Shape.Media) { if (me == null) { return; } else { part.Shape.Media = new PrimitiveBaseShape.MediaList(new MediaEntry[part.GetNumberOfSides()]); } } if (part.Shape.Media[face] == null) //If it doesn't exist, set the default parameters for it { me.InteractPermissions = MediaPermission.All; } lock (part.Shape.Media) part.Shape.Media[face] = me; UpdateMediaUrl(part, UUID.Zero); SetPartMediaFlags(part, face, me != null); part.ScheduleUpdate(PrimUpdateFlags.FullUpdate); part.TriggerScriptChangedEvent(Changed.MEDIA); }
public MediaEntry GetMediaEntry(ISceneChildEntity part, int face) { MediaEntry me = null; CheckFaceParam(part, face); List <MediaEntry> media = part.Shape.Media; if (null == media) { me = null; } else { lock (media) me = media[face]; // TODO: Really need a proper copy constructor down in libopenmetaverse if (me != null) { me = MediaEntry.FromOSD(me.GetOSD()); } } // MainConsole.Instance.DebugFormat("[MOAP]: GetMediaEntry for {0} face {1} found {2}", part.Name, face, me); return(me); }
public MediaEntry GetMediaEntry(SceneObjectPart part, int face) { MediaEntry me = null; CheckFaceParam(part, face); List <MediaEntry> media = part.Shape.Media; if (null == media) { me = null; } else { lock (media) me = media[face]; if (me != null) { Primitive.TextureEntry te = part.Shape.Textures; Primitive.TextureEntryFace teFace = te.GetFace((uint)face); if (teFace != null && teFace.MediaFlags) { me = MediaEntry.FromOSD(me.GetOSD()); } } } // m_log.DebugFormat("[MOAP]: GetMediaEntry for {0} face {1} found {2}", part.Name, face, me); return(me); }
public void SetMediaEntry(ISceneChildEntity part, int face, MediaEntry me) { CheckFaceParam(part, face); if (null == part.Shape.Media) { if (me == null) { return; } else { part.Shape.Media = new PrimitiveBaseShape.MediaList(new MediaEntry[part.GetNumberOfSides()]); } } lock (part.Shape.Media) part.Shape.Media[face] = me; UpdateMediaUrl(part, UUID.Zero); SetPartMediaFlags(part, face, me != null); part.ScheduleUpdate(PrimUpdateFlags.FullUpdate); part.TriggerScriptChangedEvent(Changed.MEDIA); }
/// <summary> /// Set the media entry on the face of the given part. /// </summary> /// <param name="part">/param> /// <param name="face"></param> /// <param name="me">If null, then the media entry is cleared.</param> public void SetMediaEntry(SceneObjectPart part, int face, MediaEntry me) { // m_log.DebugFormat("[MOAP]: SetMediaEntry for {0}, face {1}", part.Name, face); CheckFaceParam(part, face); if (null == part.Shape.Media) { if (me == null) { return; } else { part.Shape.Media = new PrimitiveBaseShape.MediaList(new MediaEntry[part.GetNumberOfSides()]); } } lock (part.Shape.Media) part.Shape.Media[face] = me; UpdateMediaUrl(part, UUID.Zero); SetPartMediaFlags(part, face, me != null); part.ParentGroup.HasGroupChanged = true; part.ScheduleFullUpdate(); part.TriggerScriptChangedEvent(Changed.MEDIA); }
public IActionResult Update(MediaEntry mediaEntry) { mediaEntry.LastModified = System.DateTime.Now; repository.UpdateMediaEntry(mediaEntry); int id = mediaEntry.Id; return(RedirectToAction("Detail", "MediaEntry", new { id, userId = repository.GetLoggedUser() })); }
public IActionResult Create(MediaEntry mediaEntry) { mediaEntry.LastModified = System.DateTime.Now; repository.Create(mediaEntry); int id = mediaEntry.UserId; return(RedirectToAction("Detail", "User", new { id })); }
public void Play(MediaEntry song, int priority = int.MaxValue) { DebugHelper.DebugPrint("AudioCore.Play() Song: " + song.Name + " until:" + song.EndTime); // 2014-06-04 changed _currentPriority < priority TO _currentPriority <= priority // to overcome a restart of a same song that is scheduled to play ever 3 minutes while the songs duration is actualy 4 minutes if (_currentMedia != null && (_currentMedia.TaskSource < song.TaskSource || (_currentPriority <= priority && priority != int.MaxValue))) { string reason = "_currentMedia != null, "; if (_currentMedia.TaskSource < song.TaskSource) { reason+= "_currentMedia.TaskSource < song.TaskSource. _cm.taskSource:" + _currentMedia.TaskSource + " song.tasksource:" + song.TaskSource; } if (_currentPriority <= priority && priority != int.MaxValue) { reason += "_currentPriority <= priority && priority != int.MaxValue" + " _cur.Priority:" + _currentPriority + " priority:" + priority; } Log.WriteString(LogMessageType.Debug, "AudioCore.play() Song Rejected: " + song.Name + " Priority:" + priority + " Reason: " + reason); Log.WriteString(LogMessageType.Debug, "_currentMedia != NULL, Name" + _currentMedia.Name + " next:" + _currentMedia.NextEligibility); return; } if (_currentMedia != null || _currentStream != null) // 2013-09-03 changed. was: currentStream == null { Log.WriteString(LogMessageType.Debug, "Stop current media" ); _remainingPlays = 0; // 2014-05-31 : RvS Added Stop(); } _currentPriority = priority; _currentMedia = song; if (song.Name.EndsWith(".m3u")) { _remainingPlays = 0; var t = new Thread(() => PlayListPlayThread(song, priority)); t.Start(); return; } _remainingPlays = song.RepeatCount; if (File.Exists(Settings.FileSystem.RootDir + Settings.FileSystem.MediaDir + song.Name)) { _currentStream = new FileStream(Settings.FileSystem.RootDir + Settings.FileSystem.MediaDir + song.Name, FileMode.Open, FileAccess.Read, FileShare.Read,32768); AudioModule.PlayFile(_currentStream, _currentMedia.PlayUntil); OnNowPlaying(song.Name); } else { OnNowPlaying("Missing file"); _currentPriority = int.MaxValue; // B73 : added to prevent next song to be rejected. } }
public Task AddMediaAsync(MediaEntry media, CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); return(Task.Run(async() => { AddMedia(media); await _events.OnAddedAsync(this, media, cancellationToken); }, cancellationToken)); }
public IActionResult Update(int id, int userId) { MediaEntry mediaEntry = repository.GetMediaEntryById(id); if (mediaEntry != null && userId == repository.GetLoggedUser()) { mediaEntry.UserId = repository.GetLoggedUser(); return(View(mediaEntry)); } return(RedirectToAction("Detail", "User", new { id = repository.GetLoggedUser() })); }
public IActionResult Delete(int id, int userId) { MediaEntry mediaEntry = repository.GetMediaEntryById(id); if (mediaEntry != null) { return(View(mediaEntry)); } id = userId; return(RedirectToAction("Detail", "User", new { id })); }
private IEnumerable <MediaEntry> Get(CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); using var tx = env.Value.BeginTransaction(TransactionBeginFlags.ReadOnly); using var db = tx.OpenDatabase(configuration: Config); using var cursor = tx.CreateCursor(db); var results = new List <MediaEntry>(); var key = _mediaKeyBuilder.GetAllKey(); if (cursor.SetRange(key) != MDBResultCode.Success) { return(NoEntries); } var current = cursor.GetCurrent(); while (current.resultCode == MDBResultCode.Success && !cancellationToken.IsCancellationRequested) { unsafe { var value = current.value.AsSpan(); fixed(byte *buf = &value.GetPinnableReference()) { var ms = new UnmanagedMemoryStream(buf, value.Length); var br = new BinaryReader(ms); var context = new LogDeserializeContext(br, _typeProvider); var entry = new MediaEntry(context); results.Add(entry); } var next = cursor.Next(); if (next == MDBResultCode.Success) { current = cursor.GetCurrent(); } else { break; } } } return(results); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } MediaEntry = await _context.MediaEntries.FirstOrDefaultAsync(m => m.Id == id); if (MediaEntry == null) { return(NotFound()); } return(Page()); }
public void SetMediaEntry(SceneObjectPart part, int face, MediaEntry me) { CheckFaceParam(part, face); if (null == part.Shape.Media) { part.Shape.Media = new PrimitiveBaseShape.MediaList(new MediaEntry[part.GetNumberOfSides()]); } lock (part.Shape.Media) part.Shape.Media[face] = me; UpdateMediaUrl(part, UUID.Zero); part.ScheduleFullUpdate(); part.TriggerScriptChangedEvent(Changed.MEDIA); }
public static void Run() { // Get keywords. Read Frisim. Parse. Store. string[] keywords = MediaEntries.GetOldMediaKeywords(); foreach (string keyword in keywords) { // string rssUrl = String.Format("http://sesam.se/search/?c=m&q={0}&&output=rss", keyword.ToLower()); string rssUrl = String.Format("http://www.frisim.com/rss/?q={0}&k=nyheter", keyword.ToLower()); // Read the RSS URL into memory, then feed RssReader from a MemoryStream HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(rssUrl); request.UserAgent = "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9b5) Gecko/2008050509 Firefox/3.0b5"; HttpWebResponse resp = (HttpWebResponse)request.GetResponse(); RssReader reader = new RssReader(resp.GetResponseStream()); try { Rss rss = reader.Read(); foreach (RssChannelItem item in rss.Channel.Items) { // We want the title, media name, link and pubdate. string url = item.Link; DateTime dateTime = item.PubDate; string title = item.Title; string mediaName = item.Categories[0].Name; MediaEntry.CreateFromKeyword(keyword, mediaName, false, url, title, dateTime); } } catch (Exception e) { throw new ReaderException("feed:" + rssUrl + "Status=" + resp.StatusCode, e); } finally { request.GetResponse().GetResponseStream().Close(); } } }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } MediaEntry = await _context.MediaEntries.FindAsync(id); if (MediaEntry != null) { _context.MediaEntries.Remove(MediaEntry); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public void TestSetMediaUrl() { TestHelpers.InMethod(); string homeUrl = "opensimulator.org"; SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart; MediaEntry me = new MediaEntry() { HomeURL = homeUrl }; m_module.SetMediaEntry(part, 1, me); Assert.That(part.Shape.Media[1].HomeURL, Is.EqualTo(homeUrl)); Assert.That(part.MediaUrl, Is.EqualTo("x-mv:0000000000/" + UUID.Zero)); Assert.That(part.Shape.Textures.FaceTextures[1].MediaFlags, Is.True); }
public void TestClearMediaUrl() { TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart; MediaEntry me = new MediaEntry(); m_module.SetMediaEntry(part, 1, me); m_module.ClearMediaEntry(part, 1); Assert.That(part.Shape.Media[1], Is.EqualTo(null)); // Although we've cleared one face, other faces may still be present. So we need to check for an // update media url version Assert.That(part.MediaUrl, Is.EqualTo("x-mv:0000000001/" + UUID.Zero)); // By changing media flag to false, the face texture once again becomes identical to the DefaultTexture. // Therefore, when libOMV reserializes it, it disappears and we are left with no face texture in this slot. // Not at all confusing, eh? Assert.That(part.Shape.Textures.FaceTextures[1], Is.Null); }
protected void OnSceneObjectPartCopy(SceneObjectPart copy, SceneObjectPart original, bool userExposed) { if (original.Shape.Media != null) { PrimitiveBaseShape.MediaList dupeMedia = new PrimitiveBaseShape.MediaList(); lock (original.Shape.Media) { foreach (MediaEntry me in original.Shape.Media) { if (me != null) { dupeMedia.Add(MediaEntry.FromOSD(me.GetOSD())); } else { dupeMedia.Add(null); } } } copy.Shape.Media = dupeMedia; } }
private void AddMedia(MediaEntry media) { if (media.Uuid == default) { media.Uuid = Guid.NewGuid(); } var ms = new MemoryStream(); var bw = new BinaryWriter(ms); media.Serialize(new LogSerializeContext(bw, _typeProvider), false); var value = ms.ToArray(); using var tx = env.Value.BeginTransaction(TransactionBeginFlags.None); using var db = tx.OpenDatabase(configuration: Config); var key = _mediaKeyBuilder.GetKey(media); tx.Put(db, key, value, PutOptions.NoOverwrite); // index by media type // index by hashes (check-sums, spectral, etc.) // full text search on name and meta-data // allow only streaming out the header data, via MediaEntryHeader // allow ranged requests for streaming var result = tx.Commit(); if (result != MDBResultCode.Success) { throw new InvalidOperationException(); } }
private void PlayListPlayThread(MediaEntry mediaEntry, int priority) { _currentPlayList = new CurrentPlayList(mediaEntry.Name, mediaEntry.Shuffle); var single = new MediaEntry { EndTime = mediaEntry.EndTime, Every = mediaEntry.Every, NextEligibility = mediaEntry.NextEligibility, PlayDate = mediaEntry.PlayDate, PlayDay = mediaEntry.PlayDay, PlayUntil = mediaEntry.PlayUntil, RepeatCount = 0, //mediaEntry.RepeatCount, Shuffle = mediaEntry.Shuffle, StartTime = mediaEntry.StartTime, Type = mediaEntry.Type }; _currentPlayList.GetNextSongFileName(ref single.Name, ref single.AfterPlayPauseInSeconds); _currentMedia = null; // KILL try { for (int i = 0; i <= mediaEntry.RepeatCount && _currentPlayList != null; i++) { do { Play(single, priority); // Wait as long the song in playing while (!AudioModule.Idle) { Thread.Sleep(100); } if (_currentPlayList == null) return; // If defined by the user, insert a pause before next song to play. if (single.AfterPlayPauseInSeconds != 0) { // check every 100mSec for user stop request int countDown = single.AfterPlayPauseInSeconds*10; while (_currentPlayList != null) { Thread.Sleep(100); if (--countDown < 0) { break; } DebugHelper.Print(countDown.ToString()); } } _currentPlayList.GetNextSongFileName(ref single.Name, ref single.AfterPlayPauseInSeconds); // single.Name = _currentPlayList.GetNextSongFileName(); } while (single.Name != ""); if (mediaEntry.RepeatCount > 0) { if (mediaEntry.Shuffle) { _currentPlayList.ReShuffle(); } else { _currentPlayList.ResetList(); } //single.Name = _currentPlayList.GetNextSongFileName(); _currentPlayList.GetNextSongFileName(ref single.Name, ref single.AfterPlayPauseInSeconds); } } } catch { ; } }
private void OnMusicFinished() { try { DebugHelper.Print("in OnMusicFinished"); if (_currentMedia == null) return; if (_remainingPlays-- > 0) { DebugHelper.Print("_remainingPlays:" + _remainingPlays); AudioModule.PlayFile(_currentStream, _currentMedia.PlayUntil); } else { DebugHelper.Print("Closing stream"); OnNowPlaying(" "); // TODO : change to clear the line _currentStream.Close(); _currentStream.Dispose(); _currentStream = null; _currentMedia = null; } } catch (Exception exception) { Log.WriteException(exception,"!!!!!!!!!!!!!!!"); _currentMedia = null; // B73: To make sure the next schedule is not rejected } }
/// <summary> /// Received from the viewer if a user has changed the url of a media texture. /// </summary> /// <param name="request"></param> /// <param name="path"></param> /// <param name="httpRequest"></param> /// <param name="httpResponse"></param> /// <returns></returns> protected byte[] HandleObjectMediaNavigateMessage(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { // MainConsole.Instance.DebugFormat("[MOAP]: Got ObjectMediaNavigate request [{0}]", request); OSDMap osd = (OSDMap)OSDParser.DeserializeLLSDXml(HttpServerHandlerHelpers.ReadFully(request)); ObjectMediaNavigateMessage omn = new ObjectMediaNavigateMessage(); omn.Deserialize(osd); UUID primId = omn.PrimID; ISceneChildEntity part = m_scene.GetSceneObjectPart(primId); if (null == part) { MainConsole.Instance.WarnFormat( "[MOAP]: Received an ObjectMediaNavigateMessage for prim {0} but this doesn't exist in region {1}", primId, m_scene.RegionInfo.RegionName); return(MainServer.BlankResponse); } UUID agentId = default(UUID); lock (m_omuCapUsers) agentId = m_omuCapUsers[path]; if (!m_scene.Permissions.CanInteractWithPrimMedia(agentId, part.UUID, omn.Face)) { return(MainServer.BlankResponse); } // MainConsole.Instance.DebugFormat( // "[MOAP]: Received request to update media entry for face {0} on prim {1} {2} to {3}", // omn.Face, part.Name, part.UUID, omn.URL); // If media has never been set for this prim, then just return. if (null == part.Shape.Media) { return(MainServer.BlankResponse); } MediaEntry me = null; lock (part.Shape.Media) me = part.Shape.Media[omn.Face]; // Do the same if media has not been set up for a specific face if (null == me) { return(MainServer.BlankResponse); } if (me.EnableWhiteList) { if (!CheckUrlAgainstWhitelist(omn.URL, me.WhiteList)) { // MainConsole.Instance.DebugFormat( // "[MOAP]: Blocking change of face {0} on prim {1} {2} to {3} since it's not on the enabled whitelist", // omn.Face, part.Name, part.UUID, omn.URL); return(MainServer.BlankResponse); } } me.CurrentURL = omn.URL; UpdateMediaUrl(part, agentId); part.ScheduleUpdate(PrimUpdateFlags.FullUpdate); part.TriggerScriptChangedEvent(Changed.MEDIA); return(OSDParser.SerializeLLSDXmlBytes(new OSD())); }
public static void loadMediaEntry(this MediaElement ele,MediaEntry entry) { ele.Source = new Uri(entry.FilePath); }
public Task OnAddedAsync(IMediaStore store, MediaEntry entry, CancellationToken cancellationToken = default) { return(_listeners.OnMediaAddedAsync(store, entry, cancellationToken)); }
public static EmailIngestionProfileAddMediaEntryRequestBuilder AddMediaEntry(MediaEntry mediaEntry, string uploadTokenId, int emailProfId, string fromAddress, string emailMsgId) { return(new EmailIngestionProfileAddMediaEntryRequestBuilder(mediaEntry, uploadTokenId, emailProfId, fromAddress, emailMsgId)); }
/// <summary> /// Received from the viewer if a user has changed the url of a media texture. /// </summary> /// <param name="request"></param> /// <param name="path"></param> /// <param name="param"></param> /// <param name="httpRequest">/param> /// <param name="httpResponse">/param> /// <returns></returns> protected void HandleObjectMediaNavigateMessage(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse, UUID agentId) { // m_log.DebugFormat("[MOAP]: Got ObjectMediaNavigate request [{0}]", request); try { OSDMap osd = (OSDMap)OSDParser.DeserializeLLSDXml(httpRequest.InputStream); ObjectMediaNavigateMessage omn = new ObjectMediaNavigateMessage(); omn.Deserialize(osd); UUID primId = omn.PrimID; SceneObjectPart part = m_scene.GetSceneObjectPart(primId); bool bad = true; MediaEntry me = null; while (true) { if (null == part) { m_log.WarnFormat( "[MOAP]: Received an ObjectMediaNavigateMessage for prim {0} but this doesn't exist in region {1}", primId, m_scene.RegionInfo.RegionName); } if (!m_scene.Permissions.CanInteractWithPrimMedia(agentId, part.UUID, omn.Face)) { break; } //m_log.DebugFormat( // "[MOAP]: Received request to update media entry for face {0} on prim {1} {2} to {3}", // omn.Face, part.Name, part.UUID, omn.URL); // If media has never been set for this prim, then just return. if (null == part.Shape.Media) { break; } lock (part.Shape.Media) me = part.Shape.Media[omn.Face]; // Do the same if media has not been set up for a specific face if (null == me) { break; } if (me.EnableWhiteList) { if (!CheckUrlAgainstWhitelist(omn.URL, me.WhiteList)) { //m_log.DebugFormat( // "[MOAP]: Blocking change of face {0} on prim {1} {2} to {3} since it's not on the enabled whitelist", // omn.Face, part.Name, part.UUID, omn.URL); break; } } bad = false; break; } if (bad) { httpResponse.StatusCode = (int)HttpStatusCode.BadRequest; return; } me.CurrentURL = omn.URL; UpdateMediaUrl(part, agentId); part.ParentGroup.HasGroupChanged = true; part.ScheduleFullUpdate(); part.TriggerScriptChangedEvent(Changed.MEDIA); httpResponse.RawBuffer = Util.UTF8.GetBytes(OSDParser.SerializeLLSDXmlString(new OSD())); httpResponse.StatusCode = (int)HttpStatusCode.OK; } catch { httpResponse.StatusCode = (int)HttpStatusCode.BadRequest; httpResponse.RawBuffer = null; } }
public static void Run() { // Get keywords. Read Knuff. Parse. Store. string[] keywords = MediaEntries.GetBlogKeywords(); foreach (string keyword in keywords) { string rssUrl = "http://knuff.se/rss/q/" + keyword; // Read the RSS URL into memory, then feed RssReader from a MemoryStream HttpWebRequest request = (HttpWebRequest)WebRequest.Create(rssUrl); request.UserAgent = "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9b5) Gecko/2008050509 Firefox/3.0b5"; HttpWebResponse resp = (HttpWebResponse)request.GetResponse(); RssReader reader = new RssReader(resp.GetResponseStream()); try { Rss rss = reader.Read(); foreach (RssChannelItem item in rss.Channel.Items) { // We want the title, link and pubdate. string url = item.Link; DateTime dateTime = item.PubDate; int dividerIndex = item.Title.LastIndexOf('('); if (item.Title.EndsWith("))")) { dividerIndex = item.Title.Substring(0, item.Title.Length - 7).LastIndexOf('('); } string title = item.Title.Substring(0, dividerIndex).Trim(); string blogName = item.Title.Substring(dividerIndex + 1, item.Title.Length - dividerIndex - 2); bool newEntry = MediaEntry.CreateFromKeyword(keyword, blogName, true, url, title, dateTime); if (newEntry) { try { PingCreeper(url); } catch (Exception) { // Ignore exceptions here, move on to the next entry } } } } catch (Exception e) { throw new ReaderException("feed:" + rssUrl + ", Status=" + resp.StatusCode, e); } finally { request.GetResponse().GetResponseStream().Close(); } } }
public void Stop(MediaEntry toStop = null) { try { if (toStop != null && toStop != _currentMedia) { DebugHelper.DebugPrint("Audiocore.Stop() : Nothing to stop"); return; } DebugHelper.Print("Audiocore.Stop()"); _currentPlayList = null; // this prevent to start a new song from the playlist in onMusicFinished() AudioModule.StopPlay(); OnNowPlaying(""); if (_currentStream != null) { _currentStream.Close(); _currentStream.Dispose(); _currentStream = null; } _currentMedia = null; } catch (Exception ex) { Log.WriteException(ex, "!!!!!!!!!!!!!!!!!!!"); _currentMedia = null; // B73: To make sure the next schedule is not rejected } }