A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 21

Thread: external swf player

  1. #1
    Senior Member
    Join Date
    May 2016
    Posts
    451

    external swf player

    hello all

    this is swishmax external swf player




    1- first problem is is that the video is larger than the display area as you see in next image



    2- second problem : how can i program the video seek Slider and total time and Elapsed time

    swishmax file : https://app.box.com/s/n9y0xg42ptce1768gpnllro6ci8hkamp



    thanks for help

  2. #2
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    Hello, I added the time text, seek slider & resized the video when it loads.

    At the _root.main.video.center_ply_btn scripting section I added a function that converts a large number to a the HMS format for example, convertTime(70) would output "00:01:10"
    PHP Code:
    var time:Number =(60*59)+650

    function convertTime(a){//send any amount of seconds to the convertTime function to produce HMS format.
    var hours=0
    var minutes=0
    var seconds=a
    var temp_hours:Number=0
    var temp_minutes:Number=0
    var temp_seconds:Number=0
    while(seconds>=60){//While seconds is a very large number, decrease by 60 and increase minutes by 1.
    minutes++
    seconds-=60
    }
    while(
    minutes>=60){//While minutes is a very large number, decrease by 60 and increase hours by 1.
    hours++
    minutes-=60
    }
    if(
    hours<10){
    hours=("0"+String(hours))//If hours is less than 10 show a zero for the nine or less, example: "9" = "09"
    }
    if(
    minutes<10){//If minutes is less than 10 show a zero for the nine or less, example: "9" = "09"
    minutes=("0"+String(minutes))
    }
    if(
    seconds<10){//If seconds is less than 10 show a zero for the nine or less, example: "9" = "09"
    seconds=("0"+String(seconds))
    }

    return(
    hours ":" minutes ":" seconds)

    download v2 (swish)
    Last edited by AS3.0; 01-27-2023 at 01:55 AM.

  3. #3
    Senior Member
    Join Date
    May 2016
    Posts
    451
    thank you very much

    1- can you hide the controls while mouse no move and if move visible again

    2- i want when i press the video stage ===> stop video and if press again ==> play again

  4. #4
    Senior Member
    Join Date
    May 2016
    Posts
    451
    no loop after finish

  5. #5
    Senior Member
    Join Date
    May 2016
    Posts
    451
    when i change external swf ====> the width and the height changed




    can you make this project global to fit any external swf

  6. #6
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    Hi, this version can play & pause when pressing the video on the stage as well as autohide the video controls.


    At the _root.main.video.center_ply_btn scripting section you have some math you can do to produce the time based on the size of the progress bar:
    PHP Code:
    _root.main.video.seekSlider.progressBar._width=_root.main.video.seekSlider._xmouse//Clicking the progress bar at the current _xmouse will give _root.main.video.seekSlider.progressBar._width     its new width.

    //You can convert the size of the bar you just resized to output a time: 
    //int(((_root.main.video.seekSlider.progressBar._width/_root.main.video.seekSlider._width)*_parent.video_stage._totalFrames)/frameRate)   <----- progress bar width divided by total width the progress bar can be multiplied by the total frames the video has divided by the frame rate of the video will produce the videos total time in seconds.
    //Sending the amount of seconds to the function convertTime will output the time in HMS format.
    //Now you can set the current video time text at the bottom left to the HMS that was just produced.
    _root.main.video.timeElapsed.text=(convertTime(int(((_root.main.video.seekSlider.progressBar._width/_root.main.video.seekSlider._width)*_parent.video_stage._totalFrames)/frameRate)))

    //You can goto the current frame you want to be on for the video based on the progress bars size you just created by using xmouse.
    //Dividing the progress bars current width by the total width it can be, than multiplying that by the total frames of the video (_totalFrames) , you can gotoAndStop at the correct frame based on the progress bars current width.
    _parent.video_stage.gotoAndStop((int((_root.main.video.seekSlider.progressBar._width/_root.main.video.seekSlider._width)*_parent.video_stage._totalFrames))) 
    At the _root.main.video.center_ply_btn scripting section for the onEnterFrame function you can check the coordinate of the mouse to see if there is a change in movement to unhide the controls:
    PHP Code:
    if(old_y!=_root.main._ymouse){//If the old_y different from the current _y coordinate.
    _root.main.video.seekSlider._visible=true//Show the controls
    _root.main.video.totalTime._visible=true
    _root
    .main.video.volumeSlider._visible=true
    _root
    .main.video.timeElapsed._visible=true
    _root
    .main.video.OnOff._visible=true
    _root
    .main.video.seekBack._visible=true
    active
    =true//Set active boolean to true.
    old_y=_root.main._ymouse
    clearTimeout
    (active_timeout)
    active_timeout=setTimeout(auto_hide,1000);//Set a timeout for the controls to hide again in 1000ms
    //When active is set to false in 1000ms the player can auto hide the controls when appropriate for line 81 because on line 57 the mouse,
    //is not hovering over the controls as well.

    At the _root.main.video.center_ply_btn scripting section for the mouse event to pause & unpause on press:
    PHP Code:
    _root.main.video.mc.onPress=function(){


    if(
    _root.main.video.OnOff._currentFrame==1){//Set the bottom left OnOff button to the correct keyframe when pressing the video movieclip at _root.main.video.mc.
    _parent.video_stage.stop()//(_parent.video_stage._totalFrame_parent.video_stage._totalFrame);
    _root.main.video.OnOff.gotoAndStop(2)//Set OnOff to frame 2 to show the playbutton when entering pause mode.
    clearTimeout(_root.main.video.center_ply_btn.timer_timeout)//Clear the timeout when entering pause mode.
    }else{
    clearTimeout(_root.main.video.center_ply_btn.timer_timeout)//Clear the timeout when entering play mode.
    //_parent.video_stage.gotoAndPlay((int((_root.main.video.seekSlider.progressBar._width/_root.main.video.seekSlider._width)*_parent.video_stage._totalFrames)))
    setTime(convertTime(int(((_root.main.video.seekSlider.progressBar._width/_root.main.video.seekSlider._width)*_parent.video_stage._totalFrames)/frameRate)))//Set the new time when entering play mode.

    _parent.video_stage.play()//(_parent.video_stage._totalFrame_parent.video_stage._totalFrame);
    _root.main.video.OnOff.gotoAndStop(1)//Set the OnOff button to the correct keyframe when entering play mode.
    }

    //If the current hour & the current minute & the current second exceeds the video time & the video is being pressed to play, restart the video to the beginning.
    if(int(_root.main.video.timeElapsed.text.split(":")[2])>=int(_root.main.video.totalTime.text.split(":")[2])&&int(_root.main.video.timeElapsed.text.split(":")[1])>=int(_root.main.video.totalTime.text.split(":")[1])&&int(_root.main.video.timeElapsed.text.split(":")[0])>=int(_root.main.video.totalTime.text.split(":")[0])){


    clearTimeout(_root.main.video.center_ply_btn.timer_timeout)//clear the video timer.
        
    _parent.video_stage.gotoAndPlay(1);//Set the current frame of the video to 1.
    _root.main.video.timeElapsed.text="00:00:00"//Set the current time of the video to 1.
    setTime("00:00:00")//Set the timer text to progress with the video.
    _parent.video_stage.gotoAndPlay((int((_root.main.video.seekSlider.progressBar._width/_root.main.video.seekSlider._width)*_parent.video_stage._totalFrames)))//Set the current frame of the video to the math of the progress bars size divided by the total with * total frames.



    }







    Send me a small snippet of the swf for the video if its still having issues resizing.

    download v3 (swish)
    Last edited by AS3.0; 01-27-2023 at 12:56 PM.

  7. #7
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    Hello, I fixed a bug when clicking the player to pause, & no loop at the end.

    download v3.2 (swish)
    Last edited by AS3.0; 01-27-2023 at 01:12 PM.

  8. #8
    Senior Member
    Join Date
    May 2016
    Posts
    451
    great but can you fit any swf

  9. #9
    Senior Member
    Join Date
    May 2016
    Posts
    451
    when video finish the Elapsed time = total time
    can you solve it

  10. #10
    Senior Member
    Join Date
    May 2016
    Posts
    451
    can you please write the comments in swish file to translate it

  11. #11
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    Hello, this version:

    -Adjusts the loaded swf's size even if its keyframe size has changed.
    -Fixes the time bug.
    -Includes added comments to translate the program syntax.

    If the size issue has not been solved, you can try sending me the file.

    download v4 (swish)
    Last edited by AS3.0; 01-27-2023 at 04:09 PM.

  12. #12
    Senior Member
    Join Date
    May 2016
    Posts
    451
    Is it possible to add smooth and quality
    if not can you tell me that is the best video to swf converter

  13. #13
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    Hi, .forceSmooth=true is for loadMovie() on images, it shouldn't have affect on an swf file.

    I got this search result that might work for you: video to swf

    You have this component that works on the video player v4 but the programming may work differently for the play/pause/time, I would just continue with the video convertors you are using:


    Should I add the thumbnail preview when seeking through the video?
    Last edited by AS3.0; 01-27-2023 at 07:47 PM.

  14. #14
    Senior Member
    Join Date
    May 2016
    Posts
    451

  15. #15
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    Bug fix for progress times minutes showing 1 digit, and also for the bar to stay its size when the video reaches the end.

    download v5 (swish)
    Last edited by AS3.0; 01-28-2023 at 02:15 AM.

  16. #16
    Senior Member
    Join Date
    May 2016
    Posts
    451
    can this project play mp4 file

  17. #17
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    Hello, Yes this one works with either mp4 & loads swf as well but I will fix the swf player again.

    At the center_ply_btn scripting section on line 33 you can use either line:
    PHP Code:
    //playVideo("swf.swf")//Play loaded swf.
    playVideo("C:\\Users\\Desktop\\Desktop\\videos\\vid2.mp4")//Play loaded mp4. 
    download v6 (swish)
    Last edited by AS3.0; 01-29-2023 at 04:35 AM.

  18. #18
    Senior Member
    Join Date
    May 2016
    Posts
    451
    when mp4 playing the background of controls invisible
    can you solve it

  19. #19
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    So you don't want the old player? ok I setup the simplest mp4 player for you.

    At the onFrame(2) scripting section you can use _root.videoPlayer.videoObject._load() to load an mp4 file:
    PHP Code:
    onFrame(2){
    stop()

    var 
    md:Boolean=false//Mouse is not down for the scrubber changes to take effect.
    onMouseDown=function(){
    if(
    _root.videoPlayer._xmouse>20&&_root.videoPlayer._xmouse<_root.videoPlayer._width-20&&_root.videoPlayer._ymouse _root.videoPlayer.videoControls._y&&_root.videoPlayer._ymouse _root.videoPlayer.videoControls._y+_root.videoPlayer.videoControls._height){//If mouse is in the scrubber area, md can = true.
    md=true
    }
    }
    onMouseUp=function(){
    md=false//On mouse up, md = false, release the scrubber.
    }

    onEnterFrame=function(){
    if(
    md){
    _root.videoPlayer.videoObject._ns.seek(((_root.videoPlayer.videoControls.seekSlider.thumb._x/(_root.videoPlayer._width-108))*getTime()))//Produce the 100% value for the scubber by subtracting scrubber x by its max position multiplied by the max amount of the seconds the video has which is the getTime function.
    }

    }
    _root.videoPlayer.gotoAndStop(1)//Set the video player to the proper frame before loading an mp4.
    _root.videoPlayer.videoObject._load("C:\\Users\\Desktop\\Desktop\\videos\\vid2.mp4")//Load the mp4.
    _root.videoPlayer.flvSound.setVolume(30);//Set the initial volume for the video.
    _root.videoPlayer.pauseVideo()//Start the video load paused.


    function getTime(){//Get the total amount of seconds of the video by combining hours, minutes & seconds to a large amount of seconds.
    var str=_root.videoPlayer.videoControls.infoBtn.clock.text.split(" ")[2]//Total time of the video.
    var type
    if(str.split(":").length<=2){
    type="minutes"
    }else if(str.split(":").length>2){
    type="hours"
    }


    if(
    type=="hours"){
    temp_hours=str.split(":")[0]
    temp_minutes=str.split(":")[1]
    temp_seconds=str.split(":")[2]
    }else{
    temp_minutes=str.split(":")[0]
    temp_seconds=str.split(":")[1]
    }
    if(
    temp_hours.length==1){
    temp_hours="0"+temp_hours
    }
    if(
    temp_minutes.length==1){
    temp_minutes="0"+temp_minutes
    }
    if(
    temp_seconds.length==1){
    temp_seconds="0"+temp_seconds
    }

    return((
    int(temp_minutes)*60)+(int(temp_hours)*60*60)+int(temp_seconds))
    }


    download mp4 player (swish)
    Last edited by AS3.0; 01-29-2023 at 05:23 PM.

  20. #20
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    Bug fix on simple mp4 player, with repeat if the video is at the end & the play button gets clicked.

    download mp4 player (swish)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center