Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9158229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:11:57+00:00 2026-06-17T13:11:57+00:00

I am using AVFoundation and MacRuby to handle video playback. I have no trouble

  • 0

I am using AVFoundation and MacRuby to handle video playback. I have no trouble getting a video to play in my AVPlayer initially using the code below:

    videoWindow.setFrame(@frame, display:true, animate:true)
    @content_view = self.videoWindow.contentView
    @content_view.wantsLayer = true
    asset = AVAsset.assetWithURL(url)       
    item = AVPlayerItem.new
    item.initWithAsset(asset)
    $video = AVPlayer.alloc.initWithPlayerItem(item)
    @player_layer = AVPlayerLayer.playerLayerWithPlayer($video)
    @player_layer.Frame = @frame
    @content_view.layer.addSublayer(@player_layer)
    @player_layer.videoGravity = AVLayerVideoGravityResize
    $video.seekToTime(CMTimeMake(4, 1))
    $video.play

Where I run into trouble is when I am trying to change the playback to a new video. To do this I am trying to use the same AVPlayer object and use the replaceCurrentItemWithPlayerItem command. When I try to run this the application stops responding.

    asset2 = AVAsset.assetWithURL(@url2)
    item2 = AVPlayerItem.new
    item2.initWithAsset(asset2)
    $video.pause
    $video.replaceCurrentItemWithPlayerItem(item2)

I have also tried performingSelectorOnMainThread but I get the same results.

    $video.performSelectorOnMainThread('replaceCurrentItemWithPlayerItem:', withObject:item2, waitUntilDone:true)

I am wondering if there is a way to reuse my AVPlayer object to play new items in?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T13:11:58+00:00Added an answer on June 17, 2026 at 1:11 pm

    This is what ended up working:

    item = AVPlayerItem.playerItemWithURL(@url)
    $video.replaceCurrentItemWithPlayerItem(item)
    

    There seemed to be some problem with how I was creating assets. I just skipped the asset and created the item directly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

iam using AVFoundation Framework to play mp3 file ,everything works great ، i have
I am trying to implement video capture in my app using AVFoundation. I have
I have some pretty basic code to capture a still image using AVFoundation. AVCaptureDeviceInput
I am reading a video file using AVFoundation framework and getting the image buffers
Anybody having trouble using AVFoundation with GC ON??? What I am experiencing is that
I am using AVFoundation and getting the sample buffer from AVCaptureVideoDataOutput , I can
Am Captuing video using AVFoundation frame work .With the help of Apple Documentation http://developer.apple.com/library/ios/#documentation/AudioVideo/Conceptual/AVFoundationPG/Articles/03_MediaCapture.html%23//apple_ref/doc/uid/TP40010188-CH5-SW2
Im trying to record video using AVFoundation I can save images but not video.
Should I used AVPlayer or MovieController? I have tried using AVPlayer but I cannot
I have been trying to do this for a few days now using AVFoundation

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.