public AVPlayList(AVConnection AVC, IMediaResource[] r, ReadyHandler rh, FailedHandler fh, object Tag) { OpenSource.Utilities.InstanceTracker.Add(this); AVRenderer AVR = AVC.Parent; _AVR = AVR; this.CurrentURIChangedHandler = new AVConnection.CurrentURIChangedHandler(UriEventSink); _Tag = Tag; /* * ArrayList branches = new ArrayList(); * ToXmlData_Custom txdc = new ToXmlData_Custom(); * foreach(IMediaResource R in r) * { * if(branches.Contains(R.Owner)==false) * { * branches.Add(R.Owner); * } * txdc.Mappings[R] = false; * } * * MediaBuilder.container container = new MediaBuilder.container("Autogenerated Playlist"); * container.ID = Guid.NewGuid().ToString(); * container.IdIsValid = true; * ToXmlFormatter txf = new ToXmlFormatter(); * txf.WriteResource = new ToXmlFormatter.ToXml_FormatResource(WriteResource); * txdc.DesiredProperties = new ArrayList(); * txdc.IsRecursive = true; * txdc.VirtualOwner = MediaBuilder.CreateContainer(container); * * // Obtain the DIDL-Lite MetaData * this.PlayListMetaData = MediaBuilder.BuildDidl(txf, txdc, branches); * if(PlayListMetaData.Length>32768) PlayListMetaData = ""; */ int TempHandle = this.GetHashCode(); bool Done = false; OnReady += rh; OnFailed += fh; AVR.OnCreateConnection2 += new AVRenderer.ConnectionHandler(ConnectionSink); AVR.OnRecycledConnection2 += new AVRenderer.ConnectionHandler(RecycledSink); AVR.OnCreateConnectionFailed2 += new AVRenderer.FailedConnectionHandler(FailedSink); if (r.Length == 1) { Done = true; _CurrentPlayListMode = PlayListMode.NOT_A_PLAYLIST; PlayListUri = ConvertLocalFileToHTTPResource(r[0]); lock (ConnectionLock) { TableOfHandles[TempHandle] = TempHandle; ConnectionSink(_AVR, AVC, TempHandle); } } if ((Done == false && AVR.SupportsProtocolInfo(new ProtocolInfoString("http-get:*:audio/mpegurl:*"))) || (Done == false && AVR.SupportsProtocolInfo(new ProtocolInfoString("http-get:*:audio/x-mpegurl:*")))) { // Build M3U Done = true; _CurrentPlayListMode = PlayListMode.M3U; CheckMiniWebServer(); StringBuilder M3U = new StringBuilder(); if (AVPlayList.EnableExtendedM3U) { M3U.Append("#EXTM3U\r\n"); } foreach (IMediaResource R in r) { if (AVPlayList.EnableExtendedM3U) { PrintExtInfLine(M3U, R); } M3U.Append(ConvertLocalFileToHTTPResource(R) + "\r\n"); } M3UString = M3U.ToString(); PlayListUri = "http://" + AVR.Interface.ToString() + ":" + MWS.LocalIPEndPoint.Port.ToString() + "/item.m3u"; lock (ConnectionLock) { TableOfHandles[TempHandle] = TempHandle; ConnectionSink(_AVR, AVC, TempHandle); } } // Use SINGLE_URI if (Done == false) { _CurrentPlayListMode = PlayListMode.SINGLE_URI; foreach (IMediaResource rsc in r) { FakePlayQueue.Enqueue(rsc); } PlayListUri = r[0].ContentUri; FakePlayQueue.Dequeue(); lock (ConnectionLock) { TableOfHandles[TempHandle] = TempHandle; ConnectionSink(_AVR, AVC, TempHandle); } } }
public AVPlayList(AVConnection AVC, IMediaResource[] r, ReadyHandler rh, FailedHandler fh, object Tag) { OpenSource.Utilities.InstanceTracker.Add(this); AVRenderer AVR = AVC.Parent; _AVR = AVR; this.CurrentURIChangedHandler = new AVConnection.CurrentURIChangedHandler(UriEventSink); _Tag = Tag; /* ArrayList branches = new ArrayList(); ToXmlData_Custom txdc = new ToXmlData_Custom(); foreach(IMediaResource R in r) { if(branches.Contains(R.Owner)==false) { branches.Add(R.Owner); } txdc.Mappings[R] = false; } MediaBuilder.container container = new MediaBuilder.container("Autogenerated Playlist"); container.ID = Guid.NewGuid().ToString(); container.IdIsValid = true; ToXmlFormatter txf = new ToXmlFormatter(); txf.WriteResource = new ToXmlFormatter.ToXml_FormatResource(WriteResource); txdc.DesiredProperties = new ArrayList(); txdc.IsRecursive = true; txdc.VirtualOwner = MediaBuilder.CreateContainer(container); // Obtain the DIDL-Lite MetaData this.PlayListMetaData = MediaBuilder.BuildDidl(txf, txdc, branches); if(PlayListMetaData.Length>32768) PlayListMetaData = ""; */ int TempHandle = this.GetHashCode(); bool Done = false; OnReady += rh; OnFailed += fh; AVR.OnCreateConnection2 += new AVRenderer.ConnectionHandler(ConnectionSink); AVR.OnRecycledConnection2 += new AVRenderer.ConnectionHandler(RecycledSink); AVR.OnCreateConnectionFailed2 += new AVRenderer.FailedConnectionHandler(FailedSink); if (r.Length == 1) { Done = true; _CurrentPlayListMode = PlayListMode.NOT_A_PLAYLIST; PlayListUri = ConvertLocalFileToHTTPResource(r[0]); lock (ConnectionLock) { TableOfHandles[TempHandle] = TempHandle; ConnectionSink(_AVR, AVC, TempHandle); } } if ((Done == false && AVR.SupportsProtocolInfo(new ProtocolInfoString("http-get:*:audio/mpegurl:*"))) || (Done == false && AVR.SupportsProtocolInfo(new ProtocolInfoString("http-get:*:audio/x-mpegurl:*")))) { // Build M3U Done = true; _CurrentPlayListMode = PlayListMode.M3U; CheckMiniWebServer(); StringBuilder M3U = new StringBuilder(); if (AVPlayList.EnableExtendedM3U) { M3U.Append("#EXTM3U\r\n"); } foreach (IMediaResource R in r) { if (AVPlayList.EnableExtendedM3U) { PrintExtInfLine(M3U, R); } M3U.Append(ConvertLocalFileToHTTPResource(R) + "\r\n"); } M3UString = M3U.ToString(); PlayListUri = "http://" + AVR.Interface.ToString() + ":" + MWS.LocalIPEndPoint.Port.ToString() + "/item.m3u"; lock (ConnectionLock) { TableOfHandles[TempHandle] = TempHandle; ConnectionSink(_AVR, AVC, TempHandle); } } // Use SINGLE_URI if (Done == false) { _CurrentPlayListMode = PlayListMode.SINGLE_URI; foreach (IMediaResource rsc in r) { FakePlayQueue.Enqueue(rsc); } PlayListUri = r[0].ContentUri; FakePlayQueue.Dequeue(); lock (ConnectionLock) { TableOfHandles[TempHandle] = TempHandle; ConnectionSink(_AVR, AVC, TempHandle); } } }