private void rdoOther_Click(object sender, EventArgs e)
        {
            PlayBackMode  = Enums.PlaybackType.UseOtherMP;
            _showControls = true;

            SetControls(_showControls);
        }
        private void rdoFFPlayStream_Click(object sender, EventArgs e)
        {
            PlayBackMode  = Enums.PlaybackType.UseFFPlayStream;
            _showControls = false;

            SetControls(_showControls);
        }
        private void Settings_Load(object sender, EventArgs e)
        {
            try {
                PlayBackMode = (Enums.PlaybackType)Properties.Settings.Default.PlaybackMode;

                switch (PlayBackMode)
                {
                case Enums.PlaybackType.UseFFPlayDirect:
                    rdoFFPlay.Checked = true;
                    _showControls     = false;
                    break;

                case Enums.PlaybackType.UseOtherMP:
                    rdoOther.Checked    = true;
                    _showControls       = true;
                    txtMPlayerPath.Text = PlayerPath = Properties.Settings.Default.PlayerPath.Trim();
                    txtCommandLine.Text = PlayerArgs = Properties.Settings.Default.PlayerArgs.Trim();
                    break;

                case Enums.PlaybackType.UseFFPlayStream:
                    rdoFFPlayStream.Checked = true;
                    _showControls           = false;
                    break;
                }

                SetControls(_showControls);
            } catch {
            }
        }
        private void PlayStream(string url, int offset)
        {
            if (url.Substring(0, 7).ToLower().CompareTo("plex://") == 0)
            {
                _isWebkit = url.Contains("webkit");

                Uri uri = new Uri(url);

                url = uri.Query.Split(new char[] { '&' })[0];
                url = url.Substring(5);
                url = HttpUtility.UrlDecode(url);

                //
                // special case for Netflix plugin
                //

                if (url.IndexOf("netflix") != -1)
                {
                    string[] parts = url.Split(new char[] { '&' });

                    string tmp = parts[0];

                    if (url.IndexOf("#resume") != -1)
                    {
                        tmp += "#resume";
                    }
                    else
                    {
                        tmp += "#restart";
                    }

                    url = tmp;

                    //
                    // end case
                    //
                }

                Clipboard.SetText(url);

                //
                // prototype RTMP support
                //
                //if (url.IndexOf("http://www.plexapp.com/player/player.php?url=") != -1)
                //{
                //    url = Uri.UnescapeDataString(url.Substring(url.IndexOf("=") + 1));
                //    PlayHttpWithDirectShow(url);
                //    return;
                //}

                if (url.IndexOf("hulu") != -1)
                {
                    _isWebkit = true;
                    _identifier = "com.plex.plugins.hulu";

                    OpenWebPage(url);
                    return;
                }

                OpenWebPage(url);

                return;

            }
            else
            {
                if (url.IndexOf("/video") != -1)

                    if ( !url.Contains(":") || url.LastIndexOf(":") > 5) {

                        url = url.Substring(url.IndexOf("/video"));

                        System.Net.Sockets.TcpClient client = new System.Net.Sockets.TcpClient();
                        client.Connect(Properties.Settings.Default.Server, 32400);

                        System.Net.Sockets.NetworkStream ns = client.GetStream();
                        StreamWriter w = new StreamWriter(ns);
                        StreamReader r = new StreamReader(ns);

                        w.WriteLine("GET " + url + " HTTP/1.0");

                        if (_useAuth == true)
                        {
                            w.WriteLine("X-Plex-User: "******"X-Plex-Pass: "******"";

                        while (s != null)
                        {
                            if (s.ToLower().IndexOf("http://") != -1)
                            {
                                newURL = s.Substring(s.IndexOf("http://"));

                                r.Close();
                                w.Close();
                                ns.Close();
                                client.Close();

            //                                PlayTranscodedWithSegments(url);
                                PlayHttpWithDirectShow(newURL);

                                break;
                            }

                            if (s.ToLower().IndexOf("plex://") != -1)
                            {
                                newURL = s.Substring(s.IndexOf("plex://"));

                                r.Close();
                                w.Close();
                                ns.Close();
                                client.Close();

                                PlayStream(newURL, offset);
                                break;
                            }

                            s = r.ReadLine();
                        }

                        return;
                    }

                if (url.Contains(FQDN()) == true)
                {

                    if (url.Contains("plugin")){
                        _playbackType = Enums.PlaybackType.UseFFPlayStream;
                    }else{
                        _playbackType = (Enums.PlaybackType)Properties.Settings.Default.PlaybackMode;
                    }

                    switch (_playbackType) {
                        case Enums.PlaybackType.UseFFPlayDirect:
                            PlayHttpWithDirectShow(url);
                            break;
                        case Enums.PlaybackType.UseOtherMP:
                            string setWatchedURL = FQDN() + "/:/scrobble?key=" + _currentRatingKey + "&identifier=com.plexapp.plugins.library";
                            SetWatchedStatus(setWatchedURL);
                            PlayHttpStreamWithOtherMP(url);
                            break;
                        case Enums.PlaybackType.UseFFPlayStream:
                            PlayTranscodedWithSegments(url);
                            break;
                        default:
                            break;
                    }

                }
                else
                {
                    PlayHttpWithDirectShow(url);
                }

            }
        }
Exemple #5
0
        private void PlayStream(string url, int offset)
        {
            if (url.Substring(0, 7).ToLower().CompareTo("plex://") == 0)
            {
                _isWebkit = url.Contains("webkit");

                Uri uri = new Uri(url);

                url = uri.Query.Split(new char[] { '&' })[0];
                url = url.Substring(5);
                url = HttpUtility.UrlDecode(url);

                //
                // special case for Netflix plugin
                //

                if (url.IndexOf("netflix") != -1)
                {
                    string[] parts = url.Split(new char[] { '&' });

                    string tmp = parts[0];

                    if (url.IndexOf("#resume") != -1)
                    {
                        tmp += "#resume";
                    }
                    else
                    {
                        tmp += "#restart";
                    }

                    url = tmp;

                    //
                    // end case
                    //
                }

                Clipboard.SetText(url);

                //
                // prototype RTMP support
                //
                //if (url.IndexOf("http://www.plexapp.com/player/player.php?url=") != -1)
                //{
                //    url = Uri.UnescapeDataString(url.Substring(url.IndexOf("=") + 1));
                //    PlayHttpWithDirectShow(url);
                //    return;
                //}

                if (url.IndexOf("hulu") != -1)
                {
                    _isWebkit   = true;
                    _identifier = "com.plex.plugins.hulu";

                    OpenWebPage(url);
                    return;
                }

                OpenWebPage(url);

                return;
            }
            else
            {
                if (url.IndexOf("/video") != -1)
                {
                    if (!url.Contains(":") || url.LastIndexOf(":") > 5)
                    {
                        url = url.Substring(url.IndexOf("/video"));

                        System.Net.Sockets.TcpClient client = new System.Net.Sockets.TcpClient();
                        client.Connect(Properties.Settings.Default.Server, 32400);

                        System.Net.Sockets.NetworkStream ns = client.GetStream();
                        StreamWriter w = new StreamWriter(ns);
                        StreamReader r = new StreamReader(ns);

                        w.WriteLine("GET " + url + " HTTP/1.0");

                        if (_useAuth == true)
                        {
                            w.WriteLine("X-Plex-User: "******"X-Plex-Pass: "******"";

                        while (s != null)
                        {
                            if (s.ToLower().IndexOf("http://") != -1)
                            {
                                newURL = s.Substring(s.IndexOf("http://"));

                                r.Close();
                                w.Close();
                                ns.Close();
                                client.Close();

//                                PlayTranscodedWithSegments(url);
                                PlayHttpWithDirectShow(newURL);

                                break;
                            }

                            if (s.ToLower().IndexOf("plex://") != -1)
                            {
                                newURL = s.Substring(s.IndexOf("plex://"));

                                r.Close();
                                w.Close();
                                ns.Close();
                                client.Close();

                                PlayStream(newURL, offset);
                                break;
                            }

                            s = r.ReadLine();
                        }

                        return;
                    }
                }

                if (url.Contains(FQDN()) == true)
                {
                    if (url.Contains("plugin"))
                    {
                        _playbackType = Enums.PlaybackType.UseFFPlayStream;
                    }
                    else
                    {
                        _playbackType = (Enums.PlaybackType)Properties.Settings.Default.PlaybackMode;
                    }

                    switch (_playbackType)
                    {
                    case Enums.PlaybackType.UseFFPlayDirect:
                        PlayHttpWithDirectShow(url);
                        break;

                    case Enums.PlaybackType.UseOtherMP:
                        string setWatchedURL = FQDN() + "/:/scrobble?key=" + _currentRatingKey + "&identifier=com.plexapp.plugins.library";
                        SetWatchedStatus(setWatchedURL);
                        PlayHttpStreamWithOtherMP(url);
                        break;

                    case Enums.PlaybackType.UseFFPlayStream:
                        PlayTranscodedWithSegments(url);
                        break;

                    default:
                        break;
                    }
                }
                else
                {
                    PlayHttpWithDirectShow(url);
                }
            }
        }