2 Replies Latest reply on Jan 18, 2011 7:55 AM by asdiopwern

    Context Menu with Video Player problem

    asdiopwern Level 1

      Hello,

      I don't think I'm doing anything silly... It seems that having a MediaContainer on the stage somehow prevents the ContextMenu dispatching a click event, has anybody else experienced this? I've created a very simple example below to illustrate the problem. If you click anywhere on the stage you'll get the correct ContextMenu (with the 'Click Me' custom item), but only if you click outside of the MediaContainer will the ContextMenuEvent be dispatched. If anybody has any ideas what I might be doing wrong, or could confirm that this might be a bug, I would greatly appreciate it.

       

       

      package
      {
          import flash.display.Sprite;       
          import org.osmf.containers.MediaContainer;   
          import org.osmf.elements.VideoElement;       
          import org.osmf.media.MediaPlayer;
          import org.osmf.net.DynamicStreamingResource;
          import org.osmf.net.DynamicStreamingItem;
          import flash.ui.ContextMenu;
          import flash.ui.ContextMenuItem;
          import flash.events.ContextMenuEvent;
         
          [SWF(width="1024", height="600", backgroundColor="#000000", frameRate="30")]
          public class OSMFPlayerTest extends Sprite
          {   
              public function OSMFPlayerTest()
              {                   
                  var dynamicStreamingResource:DynamicStreamingResource = new DynamicStreamingResource('rtmp://myhost/');
                  dynamicStreamingResource.urlIncludesFMSApplicationInstance = true;           
                  var stream1:DynamicStreamingItem = new DynamicStreamingItem('mp4:mystream.f4v', 190);
                  dynamicStreamingResource.streamItems.push(stream1);
                 
                  var videoElement:VideoElement = new VideoElement(dynamicStreamingResource);           
                  var player:MediaPlayer = new MediaPlayer(videoElement);       
                  var display:MediaContainer = new MediaContainer();           
                  display.addMediaElement(videoElement);           
                  addChild(display);              

       

                  var menu:ContextMenu = new ContextMenu();
                  menu.hideBuiltInItems();
                  var item:ContextMenuItem = new ContextMenuItem('Click Me');
                  item.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, onMenuItemClick);
                  menu.customItems.push(item);
                  this.contextMenu = menu;
              }

       

              private function onMenuItemClick(e:ContextMenuEvent):void
              {
                  trace('click');
              }
          }
      }

       

       

      Many thanks,

      Simon