Skip navigation
tanehesi
Currently Being Moderated

How to stop or remove videostream from Flash Builder View

Apr 2, 2013 5:10 PM

Greetings:

 

I'm having problems getting the video stream generated by this view to stop once the user either attempts to click the back button or changes view.  Can someone help us figure how to add a stop to the exiting back button so that when clicked the stream stops and then navigates properly?

 

Here's the code:

 

<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
  xmlns:s="library://ns.adobe.com/flex/spark" viewDeactivate="view1_viewDeactivateHandler(event)" initialize="view1_initializeHandler(event)" backgroundColor="#000000" title="{data.title}">

<fx:Script>
  <![CDATA[
   import mx.core.mx_internal;
   import mx.events.FlexEvent;
  
   import spark.events.ViewNavigatorEvent;
   protected function liveStream_completeHandler(event:Event):void
   {
    // TODO Auto-generated method stub
    if(!this.parentApplication.isTablet) theGroup.horizontalScrollPosition = liveStream.width / 2;
   
    bi.visible = false;
   }
  
   protected function view1_initializeHandler(event:FlexEvent):void
   {
    // TODO Auto-generated method stub
    systemManager.stage.addEventListener(KeyboardEvent.KEY_DOWN, deviceKeyDownHandler);
    systemManager.stage.addEventListener(KeyboardEvent.KEY_UP, deviceKeyUpHandler);
   }
  
   protected function deviceKeyDownHandler(event:KeyboardEvent):void
   {
    // TODO Auto-generated method stub
    if(event.keyCode == Keyboard.BACK && navigator.length > 1){
     event.preventDefault();
     this.liveStream.source = null;
     this.liveStream.source = VideoPlayer;
    }
   }
  
   protected function deviceKeyUpHandler(event:KeyboardEvent):void
   {
    // TODO Auto-generated method stub
    if(event.keyCode == Keyboard.BACK && navigator.length > 1){
     navigator.popView();
    }
   }
  
   protected function view1_viewDeactivateHandler(event:ViewNavigatorEvent):void
   {
    // TODO Auto-generated method stub
    systemManager.stage.removeEventListener(KeyboardEvent.KEY_DOWN, deviceKeyDownHandler);
    systemManager.stage.removeEventListener(KeyboardEvent.KEY_UP, deviceKeyUpHandler);
   }
  
  ]]>
</fx:Script>

<fx:Declarations>
  <!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:navigationContent>
  <s:Button label="Back" visible="{!this.parentApplication.isTablet}"
      click="navigator.popView()"/>
</s:navigationContent>

<s:Scroller width="100%" height="100%" id="streamScroller">
  <s:Group id="theGroup">
   <s:VideoPlayer width="100%" height="100%" complete="liveStream_completeHandler(event)" source="some_source/livestream.f4m" maintainProjectionCenter="true" scaleMode="zoom" id="liveStream"/>
  </s:Group>
</s:Scroller>
<s:BusyIndicator id="bi" width="40" height="40"  horizontalCenter="0" verticalCenter="0"/>
</s:View>

 
Replies

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points