Beispiel #1
0
        public UserMylistManager(
            NiconicoSession niconicoSession,
            Provider.LoginUserMylistProvider loginUserMylistProvider
            )
        {
            NiconicoSession         = niconicoSession;
            LoginUserMylistProvider = loginUserMylistProvider;

            _Mylists = new ObservableCollection <UserOwnedMylist>();
            Mylists  = new ReadOnlyObservableCollection <UserOwnedMylist>(_Mylists);

            NiconicoSession.LogIn += async(_, e) =>
            {
                using (await _mylistSyncLock.LockAsync())
                {
                    IsLoginUserMylistReady = false;

                    await SyncMylistGroups();

                    IsLoginUserMylistReady = true;
                }
            };

            NiconicoSession.LogOut += async(_, e) =>
            {
                using (await _mylistSyncLock.LockAsync())
                {
                    IsLoginUserMylistReady = false;

                    _Mylists.Clear();
                }
            };
        }
        public PreparePlayVideoResult(string contentId, NiconicoSession niconicoSession, NicoVideoSessionOwnershipManager ownershipManager, DmcWatchData dmcWatchData)
            : this(contentId, niconicoSession)
        {
            _ownershipManager = ownershipManager;
            _dmcWatchData     = dmcWatchData;
            IsSuccess         = _dmcWatchData != null;
            if (_dmcWatchData?.DmcWatchResponse.Video.DmcInfo != null)
            {
                AvailableQualities = _dmcWatchData.DmcWatchResponse.Video.DmcInfo.Quality.Videos
                                     .Select(x => new NicoVideoQualityEntity(x.Available, QualityIdToNicoVideoQuality(x.Id), x.Id, x.Bitrate, x.Resolution?.Width, x.Resolution?.Height))
                                     .ToImmutableArray();
            }
            else if (_dmcWatchData.DmcWatchResponse.Video.SmileInfo != null)
            {
                var video     = _dmcWatchData.DmcWatchResponse.Video;
                var smileInfo = _dmcWatchData.DmcWatchResponse.Video.SmileInfo;
                var quality   = smileInfo.Url.EndsWith("low") ? NicoVideoQuality.Smile_Low : NicoVideoQuality.Smile_Original;

                AvailableQualities = new[]
                {
                    new NicoVideoQualityEntity(false, NicoVideoQuality.Smile_Low, "", null, video.Width, video.Height),
                    new NicoVideoQualityEntity(false, NicoVideoQuality.Smile_Original, "", null, video.Width, video.Height),
                }
                .ToImmutableArray();
            }
        }
Beispiel #3
0
        public FollowManager(
            NiconicoSession niconicoSession,
            Provider.TagFollowProvider tagFollowProvider,
            Provider.MylistFollowProvider mylistFollowProvider,
            Provider.UserFollowProvider userFollowProvider,
            Provider.CommunityFollowProvider communityFollowProvider,
            Provider.ChannelFollowProvider channelFollowProvider
            )
        {
            NiconicoSession         = niconicoSession;
            TagFollowProvider       = tagFollowProvider;
            MylistFollowProvider    = mylistFollowProvider;
            UserFollowProvider      = userFollowProvider;
            CommunityFollowProvider = communityFollowProvider;
            ChannelFollowProvider   = channelFollowProvider;

            Tag       = new TagFollowInfoGroup(NiconicoSession, TagFollowProvider);
            Mylist    = new MylistFollowInfoGroup(NiconicoSession, MylistFollowProvider);
            User      = new UserFollowInfoGroup(NiconicoSession, UserFollowProvider);
            Community = new CommunityFollowInfoGroup(NiconicoSession, CommunityFollowProvider);
            Channel   = new ChannelFollowInfoGroup(NiconicoSession, ChannelFollowProvider);

            _FollowGroupsMap = new Dictionary <FollowItemType, IFollowInfoGroup>();

            _FollowGroupsMap.Add(FollowItemType.Tag, Tag);
            _FollowGroupsMap.Add(FollowItemType.Mylist, Mylist);
            _FollowGroupsMap.Add(FollowItemType.User, User);
            _FollowGroupsMap.Add(FollowItemType.Community, Community);
            _FollowGroupsMap.Add(FollowItemType.Channel, Channel);

            NiconicoSession.LogIn  += NiconicoSession_LogIn;
            NiconicoSession.LogOut += NiconicoSession_LogOut;
        }
Beispiel #4
0
        public UserMylistManager(
            NiconicoSession niconicoSession,
            Provider.LoginUserMylistProvider loginUserMylistProvider,
            Services.NotificationService notificationService
            )
        {
            _niconicoSession         = niconicoSession;
            _loginUserMylistProvider = loginUserMylistProvider;
            _notificationService     = notificationService;
            _mylists = new ObservableCollection <LoginUserMylistPlaylist>();
            Mylists  = new ReadOnlyObservableCollection <LoginUserMylistPlaylist>(_mylists);

            _niconicoSession.LogIn += async(_, e) =>
            {
                using (await _mylistSyncLock.LockAsync())
                {
                    IsLoginUserMylistReady = false;

                    await SyncMylistGroups();

                    IsLoginUserMylistReady = true;
                }
            };

            _niconicoSession.LogOut += async(_, e) =>
            {
                using (await _mylistSyncLock.LockAsync())
                {
                    IsLoginUserMylistReady = false;

                    _mylists.Clear();
                }
            };
        }
 public PreparePlayVideoResult(string contentId, NiconicoSession niconicoSession, Exception e)
     : this(contentId, niconicoSession)
 {
     Exception          = e;
     AvailableQualities = ImmutableArray <NicoVideoQualityEntity> .Empty;
     IsSuccess          = false;
 }
 public UserFollowInfoGroup(
     NiconicoSession niconicoSession,
     Provider.UserFollowProvider userFollowProvider
     )
 {
     NiconicoSession    = niconicoSession;
     UserFollowProvider = userFollowProvider;
 }
 public TagFollowInfoGroup(
     NiconicoSession niconicoSession,
     Provider.TagFollowProvider tagFollowProvider
     )
 {
     NiconicoSession   = niconicoSession;
     TagFollowProvider = tagFollowProvider;
 }
Beispiel #8
0
 public MylistFollowInfoGroup(
     NiconicoSession niconicoSession,
     Provider.MylistFollowProvider mylistFollowProvider
     )
 {
     NiconicoSession      = niconicoSession;
     MylistFollowProvider = mylistFollowProvider;
 }
 public ChannelFollowInfoGroup(
     NiconicoSession niconicoSession,
     Provider.ChannelFollowProvider channelFollowProvider
     )
 {
     NiconicoSession       = niconicoSession;
     ChannelFollowProvider = channelFollowProvider;
 }
 public NicoVideoSessionProvider(
     NicoVideoProvider nicoVideoProvider,
     NiconicoSession niconicoSession,
     NicoVideoSessionOwnershipManager nicoVideoSessionOwnershipManager
     )
 {
     _nicoVideoProvider = nicoVideoProvider;
     _niconicoSession   = niconicoSession;
     _nicoVideoSessionOwnershipManager = nicoVideoSessionOwnershipManager;
 }
Beispiel #11
0
        public VideoStreamingSession(NiconicoSession niconicoSession, NicoVideoSessionOwnershipManager.VideoSessionOwnership videoSessionOwnership)
        {
            NiconicoSession        = niconicoSession;
            _videoSessionOwnership = videoSessionOwnership;

            if (_videoSessionOwnership != null)
            {
                _videoSessionOwnership.ReturnOwnershipRequested += _videoSessionOwnership_ReturnOwnershipRequested;
            }
        }
 public SmileVideoStreamingSession(Uri videoUrl, NiconicoSession niconicoSession)
     : base(niconicoSession)
 {
     VideoUrl = videoUrl;
     if (VideoUrl.OriginalString.EndsWith("low"))
     {
         Quality = NicoVideoQuality.Smile_Low;
     }
     else
     {
         Quality = NicoVideoQuality.Smile_Original;
     }
 }
 public CommunityPageViewModel(Services.PageManager pageManager,
                               NiconicoSession niconicoSession,
                               CommunityFollowProvider followProvider,
                               CommunityProvider communityProvider,
                               FollowManager followManager,
                               NiconicoFollowToggleButtonService followToggleButtonService
                               )
     : base(pageManager)
 {
     NiconicoSession           = niconicoSession;
     FollowProvider            = followProvider;
     CommunityProvider         = communityProvider;
     FollowToggleButtonService = followToggleButtonService;
 }
Beispiel #14
0
        public SmileVideoStreamingSession(Uri videoUrl, NiconicoSession niconicoSession, NicoVideoSessionOwnershipManager.VideoSessionOwnership videoSessionOwnership)
            : base(niconicoSession, videoSessionOwnership)
        {
            VideoUrl = videoUrl;
            if (VideoUrl.OriginalString.EndsWith("low"))
            {
                Quality = NicoVideoQuality.Smile_Low;
            }
            else
            {
                Quality = NicoVideoQuality.Smile_Original;
            }

            QualityId = Quality.ToString();
        }
        public PreparePlayVideoResult(string contentId, NiconicoSession niconicoSession, NicoVideoSessionOwnershipManager ownershipManager, WatchApiResponse watchApiResponse)
            : this(contentId, niconicoSession)
        {
            _ownershipManager = ownershipManager;
            _watchApiResponse = watchApiResponse;
            IsSuccess         = _watchApiResponse != null;
            var quality = _watchApiResponse.VideoUrl.OriginalString.EndsWith("low") ? NicoVideoQuality.Smile_Low : NicoVideoQuality.Smile_Original;

            AvailableQualities = new[]
            {
                new NicoVideoQualityEntity(true, quality, quality.ToString())
            }
            .ToImmutableArray();

            // Note: スマイル鯖はいずれ無くなると見て対応を限定的にしてしまう
        }
Beispiel #16
0
        // Windows10のメディアコントロールとHohoemaのプレイリスト機能を統合してサポート

        // 外部からの次送り、前送り
        // プレイリストリセットなどに対応する
        //
        // 外部からの操作はイベントに切り出す

        // 画面の遷移自体はPageManagerに任せることにする
        // PageManagerに動画情報を渡すまでをやる

        // TODO: 「あとで見る」プレイリストをローミングフォルダへ書き出す

        public HohoemaPlaylist(
            IScheduler scheduler,
            NiconicoSession niconicoSession,
            VideoCacheManager videoCacheManager,
            PlaylistSettings playlistSettings,
            PlayerViewManager viewMan
            )
        {
            Scheduler         = scheduler;
            NiconicoSession   = niconicoSession;
            VideoCacheManager = videoCacheManager;
            PlaylistSettings  = playlistSettings;
            PlayerViewManager = viewMan;

            Player = new PlaylistPlayer(this, playlistSettings);

            MakeDefaultPlaylist();

            Player.PlayRequested += Player_PlayRequested;


            // 一般会員は再生とキャッシュDLを1ラインしか許容していないため
            // 再生終了時にキャッシュダウンロードの再開を行う必要がある
            // PlayerViewManager.NowPlaying はSecondaryViewでの再生時にFalseを示してしまうため
            // IsPlayerShowWithSecondaryViewを使ってセカンダリビューでの再生中を検出している
            _resumingObserver = new[]
            {
                // PlayerViewManager.ObserveProperty(x => x.NowPlaying).Select(x => !x),
                PlayerViewManager.ObserveProperty(x => x.IsPlayerShowWithPrimaryView).Select(x => !x),
                PlayerViewManager.ObserveProperty(x => x.IsPlayerShowWithSecondaryView).Select(x => !x),
                NiconicoSession.ObserveProperty(x => x.IsPremiumAccount).Select(x => !x)
            }
            .CombineLatestValuesAreAllTrue()
            .Throttle(TimeSpan.FromSeconds(1))
            .Subscribe(nowResumingCacheDL =>
            {
                Scheduler.Schedule(() =>
                {
                    if (nowResumingCacheDL)
                    {
                        _ = VideoCacheManager.ResumeCacheDownload();

                        // TODO: キャッシュDL再開した場合の通知
                    }
                });
            });
        }
Beispiel #17
0
 public CommunityPageViewModel(
     ApplicationLayoutManager applicationLayoutManager,
     AppearanceSettings appearanceSettings,
     Services.PageManager pageManager,
     NiconicoSession niconicoSession,
     CommunityFollowProvider followProvider,
     CommunityProvider communityProvider,
     FollowManager followManager,
     NiconicoFollowToggleButtonService followToggleButtonService
     )
 {
     ApplicationLayoutManager = applicationLayoutManager;
     _appearanceSettings      = appearanceSettings;
     PageManager               = pageManager;
     NiconicoSession           = niconicoSession;
     FollowProvider            = followProvider;
     CommunityProvider         = communityProvider;
     FollowToggleButtonService = followToggleButtonService;
 }
        public DmcVideoStreamingSession(string qualityId, DmcWatchData res, NiconicoSession niconicoSession, NicoVideoSessionOwnershipManager.VideoSessionOwnership videoSessionOwnership)
            : base(niconicoSession, videoSessionOwnership)
        {
            _DmcWatchData    = res;
            DmcWatchResponse = res.DmcWatchResponse;

            QualityId = qualityId;
            Quality   = res.ToNicoVideoQuality(qualityId);

#if DEBUG
            Debug.WriteLine($"Id/Bitrate/Resolution/Available");
            foreach (var q in _DmcWatchData.DmcWatchResponse.Video.DmcInfo.Quality.Videos)
            {
                Debug.WriteLine($"{q.Id}/{q.Bitrate}/{q.Available}/{q.Resolution}");
            }
#endif

            VideoContent = DmcWatchResponse.Video.DmcInfo.Quality.Videos.FirstOrDefault(x => x.Id == qualityId);

            if (VideoContent != null)
            {
                Debug.WriteLine($"{VideoContent.Id}/{VideoContent.Bitrate}/{VideoContent.Available}/w={VideoContent.Resolution.Width} h={VideoContent.Resolution.Height}");
            }
        }
Beispiel #19
0
        public DmcVideoStreamingSession(DmcWatchData res, NicoVideoQuality requestQuality, NiconicoSession niconicoSession)
            : base(niconicoSession)
        {
            RequestedQuality = requestQuality;
            _DmcWatchData    = res;
            DmcWatchResponse = res.DmcWatchResponse;

#if DEBUG
            Debug.WriteLine($"Id/Bitrate/Resolution/Available");
            foreach (var q in _DmcWatchData.DmcWatchResponse.Video.DmcInfo.Quality.Videos)
            {
                Debug.WriteLine($"{q.Id}/{q.Bitrate}/{q.Available}/{q.Resolution}");
            }
#endif

            VideoContent = ResetActualQuality();

            if (VideoContent == null || !VideoContent.Available)
            {
                VideoContent = DmcWatchResponse.Video.DmcInfo.Quality.Videos.FirstOrDefault(x => x.Available);
                _Quality     = NicoVideoVideoContentHelper.VideoContentToQuality(VideoContent);
            }
            else
            {
                _Quality = requestQuality;
            }

            if (VideoContent != null)
            {
                Debug.WriteLine($"quality={_Quality}");
                Debug.WriteLine($"{VideoContent.Id}/{VideoContent.Bitrate}/{VideoContent.Available}/w={VideoContent.Resolution.Width} h={VideoContent.Resolution.Height}");
            }
        }
 public NicoVideoSessionOwnershipManager(NiconicoSession niconicoSession)
 {
     _niconicoSession = niconicoSession;
 }
 public CommunityFollowInfoGroup(
     NiconicoSession niconicoSession, Provider.CommunityFollowProvider communityFollowProvider)
 {
     NiconicoSession         = niconicoSession;
     CommunityFollowProvider = communityFollowProvider;
 }
Beispiel #22
0
        // コメントの取得、とアプリケーションドメインなコメントモデルへの変換
        // コメントの投稿可否判断と投稿処理

        public CommentClient(NiconicoSession niconicoSession, string rawVideoid)
            : base(niconicoSession)
        {
            RawVideoId = rawVideoid;
        }
 public LocalVideoStreamingSession(StorageFile file, NicoVideoQuality requestQuality, NiconicoSession niconicoSession)
     : base(niconicoSession)
 {
     File    = file;
     Quality = requestQuality;
 }
 public LocalVideoStreamingSession(IStorageFile file, NicoVideoQuality requestQuality, NiconicoSession niconicoSession)
     : base(niconicoSession, null)
 {
     File      = file;
     Quality   = requestQuality;
     QualityId = requestQuality.ToString();
 }
 PreparePlayVideoResult(string contentId, NiconicoSession niconicoSession)
 {
     ContentId        = contentId;
     _niconicoSession = niconicoSession;
 }
 public VideoStreamingSession(NiconicoSession niconicoSession)
 {
     NiconicoSession = niconicoSession;
 }