avfoundation - Trouble using replaceCurrentItemWithPlayerItem when using MacRuby -


i using avfoundation , macruby handle video playback. have no trouble getting video play in avplayer using 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 run trouble when trying change playback new video. trying use same avplayer object , use replacecurrentitemwithplayeritem command. when try run application stops responding.

    asset2 = avasset.assetwithurl(@url2)     item2 = avplayeritem.new     item2.initwithasset(asset2)     $video.pause     $video.replacecurrentitemwithplayeritem(item2) 

i have tried performingselectoronmainthread same results.

    $video.performselectoronmainthread('replacecurrentitemwithplayeritem:', withobject:item2, waituntildone:true) 

i wondering if there way reuse avplayer object play new items in?

this ended working:

item = avplayeritem.playeritemwithurl(@url) $video.replacecurrentitemwithplayeritem(item) 

there seemed problem how creating assets. skipped asset , created item directly.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -