Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by dibonaj · Oct 27, 2011 at 03:58 PM · soundvideostreaming

Audio isn't playing when steaming video

Hello all.

I'm in the process of streaming video as it is clogging up my web player. I have it to where the video plays, but the sound isn't playing with it. Do I need to stream the sound separately? Or am I doing something wrong in my code that I currently have written?

Here is the code that I am using:

 var url = "";
 var www;
 var movieTexture;
 
 function Start ()
 {
     www = new WWW(url);
 
     Debug.Log("Movie Loading..." + url);
 
     movieTexture = www.movie;
     while (!movieTexture.isReadyToPlay)
          yield;
 
     Debug.Log("Movie Loaded");
 }
 
 function OnMouseDown()
 {
     guiTexture.texture = movieTexture;
 
     transform.localScale = Vector3 (0,0,0);
     transform.position = Vector3 (0.5,0.5,0);
     guiTexture.pixelInset.xMin = -movieTexture.width / 2;
     guiTexture.pixelInset.xMax = movieTexture.width / 2;
     guiTexture.pixelInset.yMin = -movieTexture.height / 2;
     guiTexture.pixelInset.yMax = movieTexture.height / 2;
 
     audio.clip = movieTexture.audioClip;
 
     movieTexture.Play();
     audio.Play();
 }
 @script RequireComponent(GUITexture)
 @script RequireComponent(AudioSource)
Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Ampler Games · Oct 27, 2011 at 09:19 PM 0
Share

The problem may be is that there is no auidio listener.

avatar image dibonaj · Oct 27, 2011 at 09:28 PM 0
Share

There is an audio listener. I am basically reworking a script that I had that played audio and video fine. The problem was that video was part of my build, and I am trying to build a web player. I removed all the videos and it took away nearly 70 $$anonymous$$Bs worth of data. So I am trying to get strea$$anonymous$$g to work, as that gets me in the ballpark of a good web player size.

avatar image dibonaj · Nov 01, 2011 at 03:02 PM 0
Share

I updated my original post to show a new script I am using. Still though, no sound plays when the video is strea$$anonymous$$g. Anyone have any thoughts as to what it might be?

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by tylo · Dec 02, 2011 at 02:37 AM

This script works for me for playing Audio & Video, and then changing to Level 1 when the video is done playing.

using UnityEngine; using System.Collections;

public class VideoStream : MonoBehaviour {

 WWW wwwData;
 public string url;
 
 // Use this for initialization
 IEnumerator Start () {
     
     wwwData = new WWW(url);
     
     m = wwwData.movie;
     
     while(!m.isReadyToPlay)
         yield return null;
     
     guiTexture.texture = m;
     
     transform.localScale = new Vector3 (0,0,0);
     transform.position = new Vector3 (0.5f,0.5f,0);
     
     Rect temp = guiTexture.pixelInset;
     
             temp.xMin = -m.width / 2;
        temp.xMax = m.width / 2;
        temp.yMin = -m.height / 2;
             temp.yMax = m.height / 2;
     
     guiTexture.pixelInset = temp;
         
     audio.clip = m.audioClip;

     yield return StartCoroutine(Play());
 }
 
 IEnumerator Play(){
     
     m.Play();
     audio.Play();
     
     while(current < m.duration){
         current += Time.deltaTime;        
     
         yield return null;
     }
     
     Application.LoadLevel(1);
 }
 
 MovieTexture m;
 float current;

}

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by jhonmiller · May 21, 2012 at 11:29 AM

I'm having same sort of problem and the answer I explore here seems to me effective. Hopefully by following these ways audio playing difficulty will be fixed. Thanks link text

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Can Unity play live streamed video and audio sources continuously? 1 Answer

How can I convert a video to .ogg format and have it play from a web server? 7 Answers

embedding link, video, sound, text. how? 2 Answers

Can I download videos at runtime? 3 Answers

How to get perfect sync between audio and video? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges