PersistentStreamPlayer icon indicating copy to clipboard operation
PersistentStreamPlayer copied to clipboard

Stream Video

Open ankushdhawan opened this issue 8 years ago • 15 comments

can we store stream video using this library

ankushdhawan avatar Feb 02 '17 07:02 ankushdhawan

@ankushdhawan it should work, yes. I haven't tested in yet in production though. Let me know how it goes for you and if there are any problems we can fix them — the goal of the library is to support audio and video, and AVPlayer should handle both agnostically.

tsheaff avatar Feb 02 '17 16:02 tsheaff

I have tested it its not work for video can you please check it On Thu, 2 Feb 2017 at 10:24 PM, Tyler Sheaffer [email protected] wrote:

@ankushdhawan https://github.com/ankushdhawan it should work, yes. I haven't tested in yet in production though. Let me know how it goes for you and if there are any problems we can fix them — the goal of the library is to support audio and video, and AVPlayer should handle both agnostically.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/calm/PersistentStreamPlayer/issues/3#issuecomment-277014688, or mute the thread https://github.com/notifications/unsubscribe-auth/AHYqiwDb0Ymrp08dvwMVDgKwEHyXPUfVks5rYgpagaJpZM4L0yW5 .

ankushdhawan avatar Feb 02 '17 16:02 ankushdhawan

@ankushdhawan please be more specific about your issue. "its not work" doesn't help me investigate.

tsheaff avatar Feb 02 '17 17:02 tsheaff

@ankushdhawan it's possible we may be using this library for video at @calm in our next version, in which case I'll be robustly testing the functionality before that. in either case, a pull request is welcomed if you're able to fix your issue (almost certainly easier than starting from scratch)

tsheaff avatar Feb 02 '17 22:02 tsheaff

video is not showing only sound is working.

ankushdhawan avatar Feb 03 '17 05:02 ankushdhawan

OK I have a few questions:

(1) what is the video format? (2) have you logged the bits coming in (or just their lengths) and compared with the video file itself? (3) are there any print statements in your Xcode debug console?

If you can paste a code sample and the video asset's URL I'm happy to investigate further.

tsheaff avatar Feb 03 '17 05:02 tsheaff

  1. Video URL:http://bnotifi.com/voyatone/media/user_video/58940de154821.mp4

let tempPath = NSURL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent((videoModel?.video_url)!)
var remoteAudioPlayer = PersistentStreamPlayer(remoteURL:url, localURL: tempPath!)
remoteAudioPlayer?.delegate = self;
remoteAudioPlayer?.addSubView(videoView) 
remoteAudioPlayer?.play()
  1. addSubView function i have create in your library
-(void)addSubView:(UIView *)parent
{
    _playerViewController.view.frame = parent.frame;
    _playerViewController.videoGravity = AVLayerVideoGravityResizeAspectFill;
    [parent addSubview:_playerViewController.view];
}

- (void)prepareToPlay
{
    self.pendingRequests = [NSMutableArray array];

    AVURLAsset *asset = [AVURLAsset URLAssetWithURL:self.audioRemoteStreamingURL options:nil];
    [asset.resourceLoader setDelegate:self queue:dispatch_get_main_queue()];
    AVPlayerItem *playerItem = [AVPlayerItem playerItemWithAsset:asset automaticallyLoadedAssetKeys:@[@"duration"]];
    self.player = [[AVPlayer alloc] initWithPlayerItem:playerItem];
    [self.player.currentItem addObserver:self
                              forKeyPath:@"status"
                                 options:NSKeyValueObservingOptionNew
                                 context:NULL];
    _playerViewController.player = self.player;
}

ankushdhawan avatar Feb 03 '17 05:02 ankushdhawan

@tsheaff I've been looking for a cached video stream solution for AVPlayer. I'll try out your library and see if I can get it working with video.

adenisonafifi avatar Feb 10 '17 19:02 adenisonafifi

@adenisonafifi cheers, much appreciated. As I mentioned, most of the hard work w/r/t streaming to disk and the buffer should be handled, it may be quite easy to get it working (although I'm not positive)

tsheaff avatar Feb 10 '17 19:02 tsheaff

It doesn't look like the AVURLAsset loads from the local file if it already exists. Is that true? I would want to avoid re-streaming the asset if it has already been saved.

adenisonafifi avatar Feb 10 '17 19:02 adenisonafifi

Yes that's a good point. That would be a nice addition, and shouldn't break anything for anyone. I was initializing AVAudioPlayer instead of a PersistentStreamPlayer when the file is present, but it makes sense to handle that functionality inside the library.

Another wrinkle is looping, right now looping is particular to audio with

@property (nonatomic, strong) AVAudioPlayer *loopingLocalAudioPlayer;

instead of a generic AVPlayer.

Not critical for v0 of video support though.

tsheaff avatar Feb 10 '17 20:02 tsheaff

I tried to integrate the streaming part to my video library and the logic also works for video streaming.

brianhei avatar Mar 17 '17 11:03 brianhei

Awesome @brianhei. I haven't had a chance to integrate PersistentStreamPlayer. Still on my roadmap though.

adenisonafifi avatar Mar 18 '17 22:03 adenisonafifi

please check https://github.com/cstlex/PersistentStreamPlayer/pull/1 for streaming from the local filesystem if available.

strfn avatar May 02 '17 15:05 strfn

@ankushdhawan can you help me for video playing using this third party?

Spaculus avatar Feb 23 '18 13:02 Spaculus