Beispiel #1
0
    def __init__(self):

        seekpoint = 0  # position in video from 0 to 1

        # Create the torrent manager
        self.torrent_manager = TorrentManager.instance()
        path = self.torrent_manager.open_torrent('res/torrents/avi.torrent')     # init torrent, get peers
        self.torrent_manager.start_torrent(seekpoint=seekpoint)   # start the download

        # Start the streaming back end
        self.streamer = Player.instance()             # create it
        self.streamer.await_file(path, seekpoint)       # this starts playing when buffer available
    def __init__(self):

        seekpoint = 0  # position in video from 0 to 1

        # Create the torrent manager
        self.torrent_manager = TorrentManager.instance()
        path = self.torrent_manager.open_torrent(
            'res/torrents/avi.torrent')  # init torrent, get peers
        self.torrent_manager.start_torrent(
            seekpoint=seekpoint)  # start the download

        # Start the streaming back end
        self.streamer = Player.instance()  # create it
        self.streamer.await_file(
            path, seekpoint)  # this starts playing when buffer available
Beispiel #3
0
    def _await_video_playable(self):
        if self.play_timer is not None:
            self.play_timer.cancel()

        print 'trying to play...', self.previous_video_position

        current_video_position = self.get_video_time()
        print 'current pos:', current_video_position

        if self.previous_video_position is None:
            self.play_seekpoint()
            self.play_timer = Timer(self.tryTorrentPlayInterval,
                                    self._await_video_playable)
            self.play_timer.daemon = True
            self.play_timer.start()

        elif self.previous_video_position == current_video_position or current_video_position == 0:
            # TODO try to use the fact that get_position() returns 0.0 when seeking fails
            self.stop()

            # Add a small delay because calling play instantly after stop may freeze python # TODO check if this is still true in web vlc
            onetime_play_timer = Timer(0.1, self.play_seekpoint)
            onetime_play_timer.daemon = True
            onetime_play_timer.start()

            self.play_timer = Timer(self.tryTorrentPlayInterval,
                                    self._await_video_playable)
            self.play_timer.daemon = True
            self.play_timer.start()

        else:
            from cloudburst.media.torrent_manager import TorrentManager
            torrent_manager = TorrentManager.instance()
            torrent_manager.torrent.set_playable(True)
            print 'Can succesfully play'
            torrent_manager.torrent.update_pieces(
                torrent_manager.torrent.seekpoint_piece)  # TODO

            if self.desired_seekpoint != 0 and torrent_manager.video_file_extension == 'MKV':
                self.pause()

                self.forward_buffer_timer = Timer(1,
                                                  self._await_forward_buffer)
                self.forward_buffer_timer.daemon = True
                self.forward_buffer_timer.start()

        self.previous_video_position = current_video_position
Beispiel #4
0
    def _await_video_playable(self):
        if self.play_timer is not None:
            self.play_timer.cancel()

        print 'trying to play...', self.previous_video_position

        current_video_position = self.get_video_time()
        print 'current pos:', current_video_position

        if self.previous_video_position is None:
            self.play_seekpoint()
            self.play_timer = Timer(self.tryTorrentPlayInterval, self._await_video_playable)
            self.play_timer.daemon = True
            self.play_timer.start()
            
        elif self.previous_video_position == current_video_position or current_video_position == 0:
            # TODO try to use the fact that get_position() returns 0.0 when seeking fails
            self.stop()

            # Add a small delay because calling play instantly after stop may freeze python # TODO check if this is still true in web vlc
            onetime_play_timer = Timer(0.1, self.play_seekpoint)
            onetime_play_timer.daemon = True
            onetime_play_timer.start()
            
            self.play_timer = Timer(self.tryTorrentPlayInterval, self._await_video_playable)
            self.play_timer.daemon = True
            self.play_timer.start()

        else:
            from cloudburst.media.torrent_manager import TorrentManager
            torrent_manager = TorrentManager.instance()
            torrent_manager.torrent.set_playable(True)
            print 'Can succesfully play'
            torrent_manager.torrent.update_pieces(torrent_manager.torrent.seekpoint_piece)     # TODO

            if self.desired_seekpoint != 0 and torrent_manager.video_file_extension == 'MKV':
                self.pause()

                self.forward_buffer_timer = Timer(1, self._await_forward_buffer)
                self.forward_buffer_timer.daemon = True
                self.forward_buffer_timer.start()

        self.previous_video_position = current_video_position
Beispiel #5
0
 def stop(self):
     self.vlc.stop()
     from cloudburst.media.torrent_manager import TorrentManager
     torrent_mananger = TorrentManager.instance()
     torrent_mananger.torrent.set_playable(False)
Beispiel #6
0
 def stop(self):
     self.vlc.stop()
     from cloudburst.media.torrent_manager import TorrentManager
     torrent_mananger = TorrentManager.instance()
     torrent_mananger.torrent.set_playable(False)