Skip navigation
ramashish13
Currently Being Moderated

How to set source in VideoPlayer via actionscript?

Jul 2, 2013 1:03 AM

Tags: #actionscript #videoplayer

Hi,

 

I'm trying to play video in spark.components.VideoPlayer by setting its source property. However, on playing the video doesn't play and comes out as garbled. Am I missing something here?

 

Here is the source code-

 

<?xml version="1.0" encoding="utf-8"?>

<!-- controls\videoplayer\VideoPlayerEvent.mxml-->

<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"

                       xmlns:s="library://ns.adobe.com/flex/spark"

                       xmlns:mx="library://ns.adobe.com/flex/mx">

    <s:layout>

        <s:VerticalLayout/>

    </s:layout>

    <fx:Script>

        <![CDATA[

            import org.osmf.events.MediaPlayerStateChangeEvent;

            import org.osmf.events.TimeEvent;

            import spark.components.VideoPlayer;

           

            protected function vpCompleteHandler(event:TimeEvent):void {

                myTA.text = "Video complete - restarting."

            }

            protected function

                vpMediaPlayerStateChangeHandler(event:MediaPlayerStateChangeEvent):vo id {

                if (event.state == "loading")

                    myTA.text = "loading ...";

                if (event.state == "playing")

                    myTA.text = "playing ...";

            }

           

            private function onPlayVideo(): void {

                videoPlayer = new VideoPlayer();

                videoPlayer.source = "file:///D:/shared/work/data/test/original/bkb2.flv";

                playerContainer.addElement(videoPlayer);

                //player.

            }

            private function onStopVideo(): void {

                videoPlayer.stop();

            }

 

            private var videoPlayer:VideoPlayer;

        ]]>

    </fx:Script>

    <s:VGroup id="playerContainer" verticalAlign="middle">

    </s:VGroup>

    <s:HGroup>

        <s:TextArea id="myTA" width="350" height="25"/>

        <s:Button label="Play Video" click="onPlayVideo();"/>       

        <s:Button label="Stop Video" click="onStopVideo();"/>       

    </s:HGroup>

   

</s:WindowedApplication>

 

Thanks in advance,

Ramashish

 

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